Skip to content

Commit b6eb138

Browse files
authored
Merge pull request #18 from G8XSU/ldk-125-upgrade
Upgrade Ldk-node to v0.4.0 / Ldk to v0.0.125
2 parents be53832 + fa5a2e4 commit b6eb138

13 files changed

Lines changed: 336 additions & 131 deletions

File tree

Cargo.lock

Lines changed: 228 additions & 84 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/src/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ enum Commands {
4646
description: String,
4747
#[arg(long)]
4848
amount_msat: Option<u64>,
49+
#[arg(long)]
50+
expiry_secs: Option<u32>,
51+
#[arg(long)]
52+
quantity: Option<u64>,
4953
},
5054
Bolt12Send {
5155
#[arg(short, long)]
@@ -95,9 +99,16 @@ async fn main() {
9599
Commands::Bolt11Send { invoice, amount_msat } => {
96100
handle_response(client.bolt11_send(Bolt11SendRequest { invoice, amount_msat }).await);
97101
},
98-
Commands::Bolt12Receive { description, amount_msat } => {
102+
Commands::Bolt12Receive { description, amount_msat, expiry_secs, quantity } => {
99103
handle_response(
100-
client.bolt12_receive(Bolt12ReceiveRequest { description, amount_msat }).await,
104+
client
105+
.bolt12_receive(Bolt12ReceiveRequest {
106+
description,
107+
amount_msat,
108+
expiry_secs,
109+
quantity,
110+
})
111+
.await,
101112
);
102113
},
103114
Commands::Bolt12Send { offer, amount_msat, quantity, payer_note } => {

protos/src/lib.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ pub struct GetNodeInfoResponse {
1616
/// Should be always set, will never be `None`.
1717
#[prost(message, optional, tag = "3")]
1818
pub current_best_block: ::core::option::Option<BestBlock>,
19-
/// The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our Lightning wallet
20-
/// to the chain tip.
19+
/// The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our Lightning wallet to
20+
/// the chain tip.
2121
///
22-
/// Will be `None` if the wallet hasnt been synced since the node was initialized.
22+
/// Will be `None` if the wallet hasn't been synced yet.
2323
#[prost(uint64, optional, tag = "4")]
24-
pub latest_wallet_sync_timestamp: ::core::option::Option<u64>,
24+
pub latest_lightning_wallet_sync_timestamp: ::core::option::Option<u64>,
2525
/// The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our on-chain
2626
/// wallet to the chain tip.
2727
///
@@ -152,6 +152,12 @@ pub struct Bolt12ReceiveRequest {
152152
/// The amount in millisatoshi to send. If unset, a "zero-amount" or variable-amount offer is returned.
153153
#[prost(uint64, optional, tag = "2")]
154154
pub amount_msat: ::core::option::Option<u64>,
155+
/// Offer expiry time in seconds.
156+
#[prost(uint32, optional, tag = "3")]
157+
pub expiry_secs: ::core::option::Option<u32>,
158+
/// If set, it represents the number of items requested, can only be set for fixed-amount offers.
159+
#[prost(uint64, optional, tag = "4")]
160+
pub quantity: ::core::option::Option<u64>,
155161
}
156162
#[allow(clippy::derive_partial_eq_without_eq)]
157163
#[derive(Clone, PartialEq, ::prost::Message)]
@@ -297,6 +303,9 @@ pub struct CloseChannelRequest {
297303
/// Whether to force close the specified channel.
298304
#[prost(bool, optional, tag = "3")]
299305
pub force_close: ::core::option::Option<bool>,
306+
/// The reason for force-closing, can only be set while force closing a channel.
307+
#[prost(string, optional, tag = "4")]
308+
pub force_close_reason: ::core::option::Option<::prost::alloc::string::String>,
300309
}
301310
#[allow(clippy::derive_partial_eq_without_eq)]
302311
#[derive(Clone, PartialEq, ::prost::Message)]
@@ -391,7 +400,7 @@ pub struct Channel {
391400
pub is_usable: bool,
392401
/// Is `true` if this channel is (or will be) publicly-announced
393402
#[prost(bool, tag = "15")]
394-
pub is_public: bool,
403+
pub is_announced: bool,
395404
/// Set of configurable parameters set by self that affect channel operation.
396405
#[prost(message, optional, tag = "16")]
397406
pub channel_config: ::core::option::Option<ChannelConfig>,

protos/src/proto/ldk_node_server.proto

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ message GetNodeInfoResponse {
1818
// Should be always set, will never be `None`.
1919
BestBlock current_best_block = 3;
2020

21-
// The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our Lightning wallet
22-
// to the chain tip.
21+
// The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our Lightning wallet to
22+
// the chain tip.
2323
//
24-
// Will be `None` if the wallet hasnt been synced since the node was initialized.
25-
optional uint64 latest_wallet_sync_timestamp = 4;
24+
// Will be `None` if the wallet hasn't been synced yet.
25+
optional uint64 latest_lightning_wallet_sync_timestamp = 4;
2626

2727
// The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our on-chain
2828
// wallet to the chain tip.
@@ -147,6 +147,12 @@ message Bolt12ReceiveRequest {
147147

148148
// The amount in millisatoshi to send. If unset, a "zero-amount" or variable-amount offer is returned.
149149
optional uint64 amount_msat = 2;
150+
151+
// Offer expiry time in seconds.
152+
optional uint32 expiry_secs = 3;
153+
154+
// If set, it represents the number of items requested, can only be set for fixed-amount offers.
155+
optional uint64 quantity = 4;
150156
}
151157

152158
message Bolt12ReceiveResponse {
@@ -273,6 +279,9 @@ message CloseChannelRequest {
273279

274280
// Whether to force close the specified channel.
275281
optional bool force_close = 3;
282+
283+
// The reason for force-closing, can only be set while force closing a channel.
284+
optional string force_close_reason = 4;
276285
}
277286

278287
message CloseChannelResponse {
@@ -364,7 +373,7 @@ message Channel {
364373
bool is_usable = 14;
365374

366375
// Is `true` if this channel is (or will be) publicly-announced
367-
bool is_public = 15;
376+
bool is_announced = 15;
368377

369378
// Set of configurable parameters set by self that affect channel operation.
370379
ChannelConfig channel_config = 16;
@@ -427,11 +436,9 @@ message OutPoint {
427436
}
428437

429438
message BestBlock {
430-
431439
// The block’s hash
432440
string block_hash = 1;
433441

434442
// The height at which the block was confirmed.
435443
uint32 height = 2;
436-
437444
}

server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", branch = "main" }
7+
ldk-node = { version = "0.4.0", default-features = false }
88
serde = { version = "1.0.203", default-features = false, features = ["derive"] }
99
serde_json = { version = "1.0.118", default-features = false }
1010
hyper = { version = "1", default-features = false, features = ["server", "http1"] }

server/src/api/bolt11_send.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ pub(crate) fn handle_bolt11_send_request(
1414
.map_err(|_| ldk_node::NodeError::InvalidInvoice)?;
1515

1616
let payment_id = match request.amount_msat {
17-
None => node.bolt11_payment().send(&invoice),
18-
Some(amount_msat) => node.bolt11_payment().send_using_amount(&invoice, amount_msat),
17+
None => node.bolt11_payment().send(&invoice, None),
18+
Some(amount_msat) => node.bolt11_payment().send_using_amount(&invoice, amount_msat, None),
1919
}?;
2020

2121
let response = Bolt11SendResponse { payment_id: Bytes::from(payment_id.0.to_vec()) };

server/src/api/bolt12_receive.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ pub(crate) fn handle_bolt12_receive_request(
88
node: Arc<Node>, request: Bolt12ReceiveRequest,
99
) -> Result<Bolt12ReceiveResponse, ldk_node::NodeError> {
1010
let offer = match request.amount_msat {
11-
Some(amount_msat) => node.bolt12_payment().receive(amount_msat, &request.description)?,
12-
None => node.bolt12_payment().receive_variable_amount(&request.description)?,
11+
Some(amount_msat) => node.bolt12_payment().receive(
12+
amount_msat,
13+
&request.description,
14+
request.expiry_secs,
15+
request.quantity,
16+
)?,
17+
None => node
18+
.bolt12_payment()
19+
.receive_variable_amount(&request.description, request.expiry_secs)?,
1320
};
1421

1522
let response = Bolt12ReceiveResponse { offer: offer.to_string() };

server/src/api/bolt12_send.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ pub(crate) fn handle_bolt12_send_request(
1414
Offer::from_str(&request.offer.as_str()).map_err(|_| ldk_node::NodeError::InvalidOffer)?;
1515

1616
let payment_id = match request.amount_msat {
17-
None => node.bolt12_payment().send(&offer, request.payer_note),
18-
Some(amount_msat) => {
19-
node.bolt12_payment().send_using_amount(&offer, request.payer_note, amount_msat)
20-
},
17+
None => node.bolt12_payment().send(&offer, request.quantity, request.payer_note),
18+
Some(amount_msat) => node.bolt12_payment().send_using_amount(
19+
&offer,
20+
amount_msat,
21+
request.quantity,
22+
request.payer_note,
23+
),
2124
}?;
2225

2326
let response = Bolt12SendResponse { payment_id: Bytes::from(payment_id.0.to_vec()) };

server/src/api/close_channel.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ pub(crate) fn handle_close_channel_request(
1717
.map_err(|_| ldk_node::NodeError::InvalidPublicKey)?;
1818

1919
match request.force_close {
20-
Some(true) => node.force_close_channel(&user_channel_id, counterparty_node_id)?,
20+
Some(true) => node.force_close_channel(
21+
&user_channel_id,
22+
counterparty_node_id,
23+
request.force_close_reason,
24+
)?,
2125
_ => node.close_channel(&user_channel_id, counterparty_node_id)?,
2226
};
2327

server/src/api/get_node_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn handle_get_node_info_request(
1717
let response = GetNodeInfoResponse {
1818
node_id: node.node_id().to_string(),
1919
current_best_block: Some(best_block),
20-
latest_wallet_sync_timestamp: node_status.latest_wallet_sync_timestamp,
20+
latest_lightning_wallet_sync_timestamp: node_status.latest_lightning_wallet_sync_timestamp,
2121
latest_onchain_wallet_sync_timestamp: node_status.latest_onchain_wallet_sync_timestamp,
2222
latest_fee_rate_cache_update_timestamp: node_status.latest_fee_rate_cache_update_timestamp,
2323
latest_rgs_snapshot_timestamp: node_status.latest_rgs_snapshot_timestamp,

0 commit comments

Comments
 (0)