Skip to content

Commit

Permalink
Add quantity param to send_using_amount
Browse files Browse the repository at this point in the history
  • Loading branch information
slanesuke committed Jul 23, 2024
1 parent 8d58464 commit cfac29f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ interface Bolt12Payment {
[Throws=NodeError]
PaymentId send([ByRef]Offer offer, u64? quantity, string? payer_note);
[Throws=NodeError]
PaymentId send_using_amount([ByRef]Offer offer, string? payer_note, u64 amount_msat);
PaymentId send_using_amount([ByRef]Offer offer, u64? quantity, string? payer_note, u64 amount_msat);
[Throws=NodeError]
Offer receive(u64 amount_msat, [ByRef]string description);
[Throws=NodeError]
Expand Down
3 changes: 1 addition & 2 deletions src/payment/bolt12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,13 @@ impl Bolt12Payment {
/// If `payer_note` is `Some` it will be seen by the recipient and reflected back in the invoice
/// response.
pub fn send_using_amount(
&self, offer: &Offer, payer_note: Option<String>, amount_msat: u64,
&self, offer: &Offer, quantity: Option<u64>, payer_note: Option<String>, amount_msat: u64,
) -> Result<PaymentId, Error> {
let rt_lock = self.runtime.read().unwrap();
if rt_lock.is_none() {
return Err(Error::NotRunning);
}

let quantity = None;
let mut random_bytes = [0u8; 32];
rand::thread_rng().fill_bytes(&mut random_bytes);
let payment_id = PaymentId(random_bytes);
Expand Down
8 changes: 5 additions & 3 deletions tests/integration_tests_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,12 @@ fn simple_bolt12_send_receive() {
let offer = node_b.bolt12_payment().receive(offer_amount_msat, "asdf").unwrap();
assert!(node_a
.bolt12_payment()
.send_using_amount(&offer, None, less_than_offer_amount)
.send_using_amount(&offer, None, None, less_than_offer_amount)
.is_err());
let payment_id =
node_a.bolt12_payment().send_using_amount(&offer, None, expected_amount_msat).unwrap();
let payment_id = node_a
.bolt12_payment()
.send_using_amount(&offer, None, None, expected_amount_msat)
.unwrap();

expect_payment_successful_event!(node_a, Some(payment_id), None);
let node_a_payments = node_a.list_payments_with_filter(|p| p.id == payment_id);
Expand Down

0 comments on commit cfac29f

Please sign in to comment.