diff --git a/bindings/ldk_node.udl b/bindings/ldk_node.udl index 79b7186fe..d5c502278 100644 --- a/bindings/ldk_node.udl +++ b/bindings/ldk_node.udl @@ -130,7 +130,7 @@ interface Bolt12Payment { [Throws=NodeError] Bolt12Invoice request_refund_payment([ByRef]Refund refund); [Throws=NodeError] - Refund initiate_refund(u64 amount_msat, u32 expiry_secs); + Refund initiate_refund(u64 amount_msat, u64? quantity,u32 expiry_secs); }; interface SpontaneousPayment { diff --git a/src/payment/bolt12.rs b/src/payment/bolt12.rs index 13d3d3b0f..be1a431e1 100644 --- a/src/payment/bolt12.rs +++ b/src/payment/bolt12.rs @@ -313,7 +313,9 @@ impl Bolt12Payment { } /// Returns a [`Refund`] object that can be used to offer a refund payment of the amount given. - pub fn initiate_refund(&self, amount_msat: u64, expiry_secs: u32) -> Result { + pub fn initiate_refund( + &self, amount_msat: u64, quantity: Option, expiry_secs: u32, + ) -> Result { let mut random_bytes = [0u8; 32]; rand::thread_rng().fill_bytes(&mut random_bytes); let payment_id = PaymentId(random_bytes); @@ -337,6 +339,7 @@ impl Bolt12Payment { log_error!(self.logger, "Failed to create refund builder: {:?}", e); Error::RefundCreationFailed })? + .quantity(quantity.unwrap_or(1)) .build() .map_err(|e| { log_error!(self.logger, "Failed to create refund: {:?}", e); @@ -350,7 +353,7 @@ impl Bolt12Payment { preimage: None, secret: None, payer_note: refund.payer_note().map(|note| UntrustedString(note.to_string())), - quantity: refund.quantity(), + quantity, }; let payment = PaymentDetails::new( payment_id, diff --git a/tests/integration_tests_rust.rs b/tests/integration_tests_rust.rs index 3ca65fd8e..277645ca4 100644 --- a/tests/integration_tests_rust.rs +++ b/tests/integration_tests_rust.rs @@ -511,7 +511,7 @@ fn simple_bolt12_send_receive() { // Now node_b refunds the amount node_a just overpaid. let overpaid_amount = expected_amount_msat - offer_amount_msat; - let refund = node_b.bolt12_payment().initiate_refund(overpaid_amount, 3600).unwrap(); + let refund = node_b.bolt12_payment().initiate_refund(overpaid_amount, None, 3600).unwrap(); let invoice = node_a.bolt12_payment().request_refund_payment(&refund).unwrap(); expect_payment_received_event!(node_a, overpaid_amount);