Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 87e37fd

Browse files
committed
Mirror back refund_onchain_address in CreateOrderResponse
.. as per recent spec change.
1 parent 62ecfb4 commit 87e37fd

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/lsps1/client.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use lightning::sign::EntropySource;
2626
use lightning::util::errors::APIError;
2727
use lightning::util::logger::Level;
2828

29+
use bitcoin::Address;
2930
use bitcoin::secp256k1::PublicKey;
3031

3132
use core::ops::Deref;
@@ -188,7 +189,7 @@ where
188189
///
189190
/// The client agrees to paying channel fees according to the provided parameters.
190191
pub fn create_order(
191-
&self, counterparty_node_id: &PublicKey, order: OrderParameters,
192+
&self, counterparty_node_id: &PublicKey, order: OrderParameters, refund_onchain_address: Option<Address>,
192193
) -> RequestId {
193194
let (request_id, request_msg) = {
194195
let mut outer_state_lock = self.per_peer_state.write().unwrap();
@@ -198,7 +199,7 @@ where
198199
let mut peer_state_lock = inner_state_lock.lock().unwrap();
199200

200201
let request_id = crate::utils::generate_request_id(&self.entropy_source);
201-
let request = LSPS1Request::CreateOrder(CreateOrderRequest { order });
202+
let request = LSPS1Request::CreateOrder(CreateOrderRequest { order, refund_onchain_address });
202203
let msg = LSPS1Message::Request(request_id.clone(), request).into();
203204
peer_state_lock.pending_create_order_requests.insert(request_id.clone());
204205

src/lsps1/msgs.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ pub struct CreateOrderRequest {
8585
/// The order made.
8686
#[serde(flatten)]
8787
pub order: OrderParameters,
88+
/// The address where the LSP will send the funds if the order fails.
89+
#[serde(default)]
90+
#[serde(skip_serializing_if = "Option::is_none")]
91+
#[serde(with = "unchecked_address_option")]
92+
pub refund_onchain_address: Option<Address>,
8893
}
8994

9095
/// An object representing an LSPS1 channel order.
@@ -107,11 +112,6 @@ pub struct OrderParameters {
107112
pub channel_expiry_blocks: u32,
108113
/// May contain arbitrary associated data like a coupon code or a authentication token.
109114
pub token: Option<String>,
110-
/// The address where the LSP will send the funds if the order fails.
111-
#[serde(default)]
112-
#[serde(skip_serializing_if = "Option::is_none")]
113-
#[serde(with = "unchecked_address_option")]
114-
pub refund_onchain_address: Option<Address>,
115115
/// Indicates if the channel should be announced to the network.
116116
pub announce_channel: bool,
117117
}
@@ -196,6 +196,11 @@ pub struct OnchainPaymentInfo {
196196
/// confirmed without a confirmation.
197197
#[serde(with = "u32_fee_rate")]
198198
pub min_fee_for_0conf: FeeRate,
199+
/// The address where the LSP will send the funds if the order fails.
200+
#[serde(default)]
201+
#[serde(skip_serializing_if = "Option::is_none")]
202+
#[serde(with = "unchecked_address_option")]
203+
pub refund_onchain_address: Option<Address>,
199204
}
200205

201206
/// The state of a payment.
@@ -435,9 +440,10 @@ mod tests {
435440
"expires_at": "2015-01-25T19:29:44.612Z",
436441
"fee_total_sat": "9999",
437442
"order_total_sat": "2009999",
438-
"address": "bc1qvmsy0f3yyes6z9jvddk8xqwznndmdwapvrc0xrmhd3vqj5rhdrrq6hz49h",
443+
"address" : "bc1p5uvtaxzkjwvey2tfy49k5vtqfpjmrgm09cvs88ezyy8h2zv7jhas9tu4yr",
439444
"min_fee_for_0conf": 253,
440-
"min_onchain_payment_confirmations": 0
445+
"min_onchain_payment_confirmations": 0,
446+
"refund_onchain_address": "bc1qvmsy0f3yyes6z9jvddk8xqwznndmdwapvrc0xrmhd3vqj5rhdrrq6hz49h"
441447
}
442448
},
443449
"channel": null

0 commit comments

Comments
 (0)