Skip to content

Commit 9abedab

Browse files
committed
rpcserver: restrict invoice minimum asset unit amount
1 parent 2237594 commit 9abedab

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

rpcserver.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7382,6 +7382,17 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
73827382
return nil, fmt.Errorf("unexpected response type: %T", r)
73837383
}
73847384

7385+
// If the invoice is for an asset unit amount smaller than the minimal
7386+
// transportable amount, we'll return an error, as it wouldn't be
7387+
// payable by the network.
7388+
if acceptedQuote.MinTransportableUnits > req.AssetAmount {
7389+
return nil, fmt.Errorf("cannot create invoice over %d asset "+
7390+
"units, as the minimal transportable amount is %d "+
7391+
"units with the current rate of %v units/BTC",
7392+
req.AssetAmount, acceptedQuote.MinTransportableUnits,
7393+
acceptedQuote.AskAssetRate)
7394+
}
7395+
73857396
// Now that we have the accepted quote, we know the amount in Satoshi
73867397
// that we need to pay. We can now update the invoice with this amount.
73877398
//

0 commit comments

Comments
 (0)