From b9b66419ff9453e357ca887614e29cbc64e1df55 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Wed, 8 Jan 2020 12:25:21 -0800 Subject: [PATCH] zpay32/invoice: remove unknown required fbit check from decode This commit removes the unknown required feature bit check from the invoice decoding logic. This allows greater utility to users of the decodepayreq rpc since it can provide inspection of otherwise invalid invoices. In the prior commit, this check moved into our path finding logic, so invalid features taken from an invoice will instead cause a failure when attempting to pay. --- zpay32/invoice.go | 9 +-------- zpay32/invoice_test.go | 7 +++---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/zpay32/invoice.go b/zpay32/invoice.go index 3f8dcc2d..691c0169 100644 --- a/zpay32/invoice.go +++ b/zpay32/invoice.go @@ -956,14 +956,7 @@ func parseFeatures(data []byte) (*lnwire.FeatureVector, error) { return nil, err } - fv := lnwire.NewFeatureVector(rawFeatures, lnwire.Features) - unknownFeatures := fv.UnknownRequiredFeatures() - if len(unknownFeatures) > 0 { - return nil, fmt.Errorf("invoice contains unknown required "+ - "features: %v", unknownFeatures) - } - - return fv, nil + return lnwire.NewFeatureVector(rawFeatures, lnwire.Features), nil } // writeTaggedFields writes the non-nil tagged fields of the Invoice to the diff --git a/zpay32/invoice_test.go b/zpay32/invoice_test.go index 923e692e..41687a69 100644 --- a/zpay32/invoice_test.go +++ b/zpay32/invoice_test.go @@ -534,9 +534,8 @@ func TestDecodeEncode(t *testing.T) { { // On mainnet, please send $30 coffee beans supporting // features 9, 15, 99, and 100, using secret 0x11... - encodedInvoice: "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqpqqqqu7fz6pjqczdm3jp3qps7xntj2w2mm70e0ckhw3c5xk9p36pvk3sewn7ncaex6uzfq0vtqzy28se6pcwn790vxex7xystzumhg55p6qq9wq7td", - valid: false, - skipEncoding: true, + encodedInvoice: "lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqpqsqq40wa3khl49yue3zsgm26jrepqr2eghqlx86rttutve3ugd05em86nsefzh4pfurpd9ek9w2vp95zxqnfe2u7ckudyahsa52q66tgzcp6t2dyk", + valid: true, decodedInvoice: func() *Invoice { return &Invoice{ Net: &chaincfg.MainNetParams, @@ -710,7 +709,7 @@ func TestDecodeEncode(t *testing.T) { } if test.valid { - if err := compareInvoices(test.decodedInvoice(), invoice); err != nil { + if err := compareInvoices(decodedInvoice, invoice); err != nil { t.Errorf("Invoice decoding result %d not as expected: %v", i, err) return }