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 8, 2023
1 parent e53cb69 commit 8748ec4
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lightning_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1737,9 +1737,24 @@ 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 8748ec4

Please sign in to comment.