zpay32: add payment metadata field
This commit is contained in:
4 files changed
+75
-5
No files matched your search
+34
-5
@@ -27,6 +27,7 @@ var (
|
||||
testMillisat2500uBTC = lnwire.MilliSatoshi(250000000)
|
||||
testMillisat25mBTC = lnwire.MilliSatoshi(2500000000)
|
||||
testMillisat20mBTC = lnwire.MilliSatoshi(2000000000)
|
||||
testMillisat10mBTC = lnwire.MilliSatoshi(1000000000)
|
||||
|
||||
testPaymentHash = [32]byte{
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
@@ -49,11 +50,12 @@ var (
|
||||
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
|
||||
}
|
||||
|
||||
testEmptyString = ""
|
||||
testCupOfCoffee = "1 cup coffee"
|
||||
testCoffeeBeans = "coffee beans"
|
||||
testCupOfNonsense = "ナンセンス 1杯"
|
||||
testPleaseConsider = "Please consider supporting this project"
|
||||
testEmptyString = ""
|
||||
testCupOfCoffee = "1 cup coffee"
|
||||
testCoffeeBeans = "coffee beans"
|
||||
testCupOfNonsense = "ナンセンス 1杯"
|
||||
testPleaseConsider = "Please consider supporting this project"
|
||||
testPaymentMetadata = "payment metadata inside"
|
||||
|
||||
testPrivKeyBytes, _ = hex.DecodeString("e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734")
|
||||
testPrivKey, testPubKey = btcec.PrivKeyFromBytes(testPrivKeyBytes)
|
||||
@@ -692,6 +694,33 @@ func TestDecodeEncode(t *testing.T) {
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
// Please send 0.01 BTC with payment metadata 0x01fafaf0.
|
||||
encodedInvoice: "lnbc10m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp9wpshjmt9de6zqmt9w3skgct5vysxjmnnd9jx2mq8q8a04uqsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q2gqqqqqqsgq7hf8he7ecf7n4ffphs6awl9t6676rrclv9ckg3d3ncn7fct63p6s365duk5wrk202cfy3aj5xnnp5gs3vrdvruverwwq7yzhkf5a3xqpd05wjc",
|
||||
valid: true,
|
||||
decodedInvoice: func() *Invoice {
|
||||
return &Invoice{
|
||||
Net: &chaincfg.MainNetParams,
|
||||
MilliSat: &testMillisat10mBTC,
|
||||
Timestamp: time.Unix(1496314658, 0),
|
||||
PaymentHash: &testPaymentHash,
|
||||
Description: &testPaymentMetadata,
|
||||
Destination: testPubKey,
|
||||
PaymentAddr: &specPaymentAddr,
|
||||
Features: lnwire.NewFeatureVector(
|
||||
lnwire.NewRawFeatureVector(8, 14, 48),
|
||||
lnwire.Features,
|
||||
),
|
||||
Metadata: []byte{0x01, 0xfa, 0xfa, 0xf0},
|
||||
}
|
||||
},
|
||||
beforeEncoding: func(i *Invoice) {
|
||||
// Since this destination pubkey was recovered
|
||||
// from the signature, we must set it nil before
|
||||
// encoding to get back the same invoice string.
|
||||
i.Destination = nil
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
|
||||
Reference in new issue
Block a user