Skip to content

add support for RGB zero asset amount invoices#101

Open
bitwalt wants to merge 1 commit intoRGB-Tools:masterfrom
bitwalt:rgb-zero-amount-sendpayment-fix
Open

add support for RGB zero asset amount invoices#101
bitwalt wants to merge 1 commit intoRGB-Tools:masterfrom
bitwalt:rgb-zero-amount-sendpayment-fix

Conversation

@bitwalt
Copy link
Contributor

@bitwalt bitwalt commented Feb 25, 2026

This PR reproduce #100 and provide a fix for it

Copy link
Member

@nicbus nicbus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, please address the requested changes

also, please squash into a single commit, as this is a new feature so doesn't need a test showing it's missing beforehand

src/routes.rs Outdated
return Err(APIError::InvalidAmount(format!(
"amt_msat cannot be less than {INVOICE_MIN_MSAT} when transferring an RGB asset"
)));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previous code looks fine to me, it's not preventing the creation of an invoice with no asset amount, and the new check is preventing it from being set while reporting an amt_msat error

please revert this

pub(crate) struct SendPaymentRequest {
pub(crate) invoice: String,
pub(crate) amt_msat: Option<u64>,
pub(crate) asset_id: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this also enables paying RGB assets to invoices specifying neither the asset_id nor the asset_amount, would you please cover this case as well in a test?

please also update the openapi spec (where amt_msat is missing already)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the updated openapi spec but not the test case which uses an invoice with asset_id and asset_amount both set to None, was that intentional?

src/routes.rs Outdated
(Some(rgb_contract_id), None) => {
if amt_msat < INVOICE_MIN_MSAT {
return Err(APIError::InvalidAmount(format!(
"msat amount in invoice sending an RGB asset cannot be less than {INVOICE_MIN_MSAT}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"msat amount in invoice sending an RGB asset cannot be less than {INVOICE_MIN_MSAT}"
"amt_msat in invoice sending an RGB asset cannot be less than {INVOICE_MIN_MSAT}"

src/routes.rs Outdated
.map_err(|_| APIError::InvalidAssetID(asset_id.clone()))?;
if payload_contract_id != rgb_contract_id {
return Err(APIError::InvalidInvoice(s!(
"invoice RGB contract ID doesn't match request asset_id"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"invoice RGB contract ID doesn't match request asset_id"
"invoice RGB contract ID doesn't match the requested one"

#[serial_test::serial]
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[traced_test]
async fn rgb_invoice_without_asset_amount_can_be_paid_with_sendpayment_asset_amount() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please try to include this in an existing test, to avoid paying the cost of setting up a new one

@nicbus nicbus changed the title Rgb zero amount sendpayment fix add support for RGB zero asset amount invoices Feb 26, 2026
@bitwalt bitwalt force-pushed the rgb-zero-amount-sendpayment-fix branch from 1866139 to 3cf7a3d Compare February 26, 2026 10:35
@bitwalt
Copy link
Contributor Author

bitwalt commented Feb 26, 2026

Thanks for the review, suggested changes has been addressed

Copy link
Member

@nicbus nicbus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some more changes

pub(crate) struct SendPaymentRequest {
pub(crate) invoice: String,
pub(crate) amt_msat: Option<u64>,
pub(crate) asset_id: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the updated openapi spec but not the test case which uses an invoice with asset_id and asset_amount both set to None, was that intentional?

@bitwalt bitwalt force-pushed the rgb-zero-amount-sendpayment-fix branch from 3cf7a3d to 571728f Compare February 27, 2026 10:16
@bitwalt
Copy link
Contributor Author

bitwalt commented Feb 27, 2026

Ok requested changes should be addressed now, let me know if its okay or some more cases are needed in the test. I included the case with asset_id and asset_amount both set to None that was missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants