Skip to content

Fix is_payment_rgb logic in outbound_payment.rs – avoid incorrect inbound path check for outbound payments #24

@free-free-6

Description

@free-free-6

This PR addresses a bug introduced when refactoring HODL-related logic (based on workflow from #118 ), where outbound RGB payment validation incorrectly checks both inbound and outbound payment info paths, leading to runtime panics in specific scenarios.

🔍Reproduction Steps
Following the flow from PR #118:

  1. Set up node and channels per documentation
  2. Initiate an outbound RGB payment via /sendpayment
  3. At step 3, the node panics with:
INFO request{uri=/sendpayment request_id=...}: rgb_lightning_node: STARTED

thread 'tokio-rt-worker' panicked at rust-lightning/lightning/src/rgb_utils/mod.rs:548:51:
valid rgb payment info: Os { code: 2, kind: NotFound, message: "No such file or directory" }

thread 'tokio-rt-worker' panicked at src/utils.rs:318:14:
called `Result::unwrap()` on an `Err` value: RecvError(())

🐛 Root Cause
In [outbound_payment.rs], the helper function is_payment_rgb currently checks both outbound and inbound payment info paths:

pub(crate) fn is_payment_rgb(ldk_data_dir: &Path, payment_hash: &PaymentHash) -> bool {
    get_rgb_payment_info_path(payment_hash, ldk_data_dir, false).exists()  // outbound
        || get_rgb_payment_info_path(payment_hash, ldk_data_dir, true).exists()  // inbound ← unnecessary here
}

For outbound payment flows, only the outbound path (false) should be validated. Including the inbound check (true) causes false negatives when inbound metadata is absent—triggering the panic above.

✅Fix

  • Restrict is_payment_rgb usage in outbound contexts to check only the outbound path (false)
  • Add clarifying comments to prevent future misuse

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions