Paying an RGB LN invoice currently fails when the invoice carries RGB contract ID but no RGB amount, even if the payer provides asset_amount in sendpayment.
Problem
Some RGB payment flows need the invoice to specify the RGB asset (asset_id) while leaving the RGB quantity to the payer at payment time.
Today, this path is rejected because payment logic expects RGB amount inside the invoice itself.
Reproduction
- Create an LN invoice with:
asset_id: <valid RGB contract id>
amt_msat: <valid value>
asset_amount: null
- Call
sendpayment with:
invoice
amt_msat
asset_id
asset_amount
- Observe failure.
Expected behavior
Payment should succeed when invoice has RGB contract ID and sendpayment provides a valid asset_amount (with matching asset_id when provided).
Proposed implementation
API request changes
Extend SendPaymentRequest with optional RGB fields:
asset_id: Option<String>
asset_amount: Option<u64>
Payment resolution logic (sendpayment)
When decoding a BOLT11 invoice:
-
Invoice has RGB contract ID + RGB amount
- keep current behavior (use invoice values)
- enforce existing minimum
amt_msat checks for RGB
-
Invoice has RGB contract ID + no RGB amount
- require
asset_amount from sendpayment request
- if request
asset_id is provided, validate it matches invoice contract ID
- build RGB payment info from:
- contract ID from invoice
- amount from request
asset_amount
- proceed with normal payment flow and persistence
-
Invoice has RGB amount + no RGB contract ID
- keep current invalid invoice error path
Paying an RGB LN invoice currently fails when the invoice carries RGB contract ID but no RGB amount, even if the payer provides
asset_amountinsendpayment.Problem
Some RGB payment flows need the invoice to specify the RGB asset (
asset_id) while leaving the RGB quantity to the payer at payment time.Today, this path is rejected because payment logic expects RGB amount inside the invoice itself.
Reproduction
asset_id: <valid RGB contract id>amt_msat: <valid value>asset_amount: nullsendpaymentwith:invoiceamt_msatasset_idasset_amountExpected behavior
Payment should succeed when invoice has RGB contract ID and
sendpaymentprovides a validasset_amount(with matchingasset_idwhen provided).Proposed implementation
API request changes
Extend
SendPaymentRequestwith optional RGB fields:asset_id: Option<String>asset_amount: Option<u64>Payment resolution logic (
sendpayment)When decoding a BOLT11 invoice:
Invoice has RGB contract ID + RGB amount
amt_msatchecks for RGBInvoice has RGB contract ID + no RGB amount
asset_amountfromsendpaymentrequestasset_idis provided, validate it matches invoice contract IDasset_amountInvoice has RGB amount + no RGB contract ID