Skip to content

Commit

Permalink
lightning_client: allow empty hash on AMP invoices
Browse files Browse the repository at this point in the history
  • Loading branch information
guggero committed Sep 18, 2023
1 parent cd37d1a commit ae272a0
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions lightning_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1737,9 +1737,23 @@ func (s *lightningClient) LookupInvoice(ctx context.Context,

// unmarshalInvoice creates an invoice from the rpc response provided.
func unmarshalInvoice(resp *lnrpc.Invoice) (*Invoice, error) {
hash, err := lntypes.MakeHash(resp.RHash)
if err != nil {
return nil, err
var (
hash lntypes.Hash
err error
)
switch {
case !resp.IsAmp && len(resp.RHash) == 0:
return nil, fmt.Errorf("non-AMP invoice is missing hash")

case resp.IsAmp && len(resp.RHash) == 0:
// AMP invoices do not have an invoice-level hash, so we just
// leave it empty.

default:
hash, err = lntypes.MakeHash(resp.RHash)
if err != nil {
return nil, err
}
}

invoice := &Invoice{
Expand Down

0 comments on commit ae272a0

Please sign in to comment.