zpay32: add functional opt to error out on unknown feature bit

This commit adds two functional options to the zpay32.Decode function.
`WithKnownFeatureBits` allows the caller to overwrite the default set of
known feature bits used by the function.
`WithErrorOnUnknownFeatureBit` allows the caller to instruct the
function to error out if the invoice that is decoded contaijns unknown
feature bits. We then use this new error-out option from the
`rpcServer`'s `extractPaymentIntent` method.
This commit is contained in:
Elle Mouton
2024-08-06 12:33:56 +02:00
parent e4619afc08
commit 48a9a8d20e
3 changed files with 133 additions and 4 deletions

View File

@ -5210,6 +5210,7 @@ func (r *rpcServer) extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPayme
if rpcPayReq.PaymentRequest != "" {
payReq, err := zpay32.Decode(
rpcPayReq.PaymentRequest, r.cfg.ActiveNetParams.Params,
zpay32.WithErrorOnUnknownFeatureBit(),
)
if err != nil {
return payIntent, err