Skip to content

RGB LN invoice payment should support providing asset_amount in sendpayment #100

@bitwalt

Description

@bitwalt

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

  1. Create an LN invoice with:
    • asset_id: <valid RGB contract id>
    • amt_msat: <valid value>
    • asset_amount: null
  2. Call sendpayment with:
    • invoice
    • amt_msat
    • asset_id
    • asset_amount
  3. 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:

  1. Invoice has RGB contract ID + RGB amount

    • keep current behavior (use invoice values)
    • enforce existing minimum amt_msat checks for RGB
  2. 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
  3. Invoice has RGB amount + no RGB contract ID

    • keep current invalid invoice error path

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions