multi: update PaymentAddr to use fn.Option
Since it is allowed to not be set and so can lead to nil deref panics if it is a pointer.
This commit is contained in:
14 files changed
+87
-70
No files matched your search
+8
-7
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/btcsuite/btcd/btcutil/bech32"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
@@ -301,14 +302,14 @@ func writeTaggedFields(bufferBase32 *bytes.Buffer, invoice *Invoice) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if invoice.PaymentAddr != nil {
|
||||
err := writeBytes32(
|
||||
bufferBase32, fieldTypeS, *invoice.PaymentAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := fn.MapOptionZ(invoice.PaymentAddr, func(addr [32]byte) error {
|
||||
return writeBytes32(bufferBase32, fieldTypeS, addr)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if invoice.Features.SerializeSize32() > 0 {
|
||||
var b bytes.Buffer
|
||||
err := invoice.Features.RawFeatureVector.EncodeBase32(&b)
|
||||
|
||||
Reference in new issue
Block a user