Skip to content

Commit ed12e65

Browse files
committed
Bump to LDK main (4e32d852)
We bump our LDK dependency to 0.2-devel, up to commit `4e32d85249359d8ef8ece97d89848e40154363ab`.
1 parent 66b1a88 commit ed12e65

28 files changed

+690
-778
lines changed

Cargo.toml

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,38 +28,53 @@ panic = 'abort' # Abort on panic
2828
default = []
2929

3030
[dependencies]
31-
lightning = { version = "0.1.0", features = ["std"] }
32-
lightning-types = { version = "0.2.0" }
33-
lightning-invoice = { version = "0.33.0", features = ["std"] }
34-
lightning-net-tokio = { version = "0.1.0" }
35-
lightning-persister = { version = "0.1.0" }
36-
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
37-
lightning-rapid-gossip-sync = { version = "0.1.0" }
38-
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "rest-client", "tokio"] }
39-
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time", "electrum"] }
40-
lightning-liquidity = { version = "0.1.0", features = ["std"] }
31+
#lightning = { version = "0.1.0", features = ["std"] }
32+
#lightning-types = { version = "0.2.0" }
33+
#lightning-invoice = { version = "0.33.0", features = ["std"] }
34+
#lightning-net-tokio = { version = "0.1.0" }
35+
#lightning-persister = { version = "0.1.0" }
36+
#lightning-background-processor = { version = "0.1.0" }
37+
#lightning-rapid-gossip-sync = { version = "0.1.0" }
38+
#lightning-block-sync = { version = "0.1.0", features = ["rest-client", "rpc-client", "tokio"] }
39+
#lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time", "electrum"] }
40+
#lightning-liquidity = { version = "0.1.0", features = ["std"] }
41+
#lightning-macros = { version = "0.1.0" }
4142

4243
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
4344
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
4445
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
4546
#lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
4647
#lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
47-
#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["futures"] }
48+
#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
4849
#lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
49-
#lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rpc-client", "tokio"] }
50+
#lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rest-client", "rpc-client", "tokio"] }
5051
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "electrum", "time"] }
5152
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
53+
#lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
54+
55+
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab", features = ["std"] }
56+
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab" }
57+
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab", features = ["std"] }
58+
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab" }
59+
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab" }
60+
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab" }
61+
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab" }
62+
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab", features = ["rest-client", "rpc-client", "tokio"] }
63+
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab", features = ["esplora-async-https", "electrum", "time"] }
64+
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab" }
65+
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab" }
5266

5367
#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
5468
#lightning-types = { path = "../rust-lightning/lightning-types" }
5569
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
5670
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
5771
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
58-
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
72+
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor" }
5973
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
60-
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client", "tokio"] }
74+
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rest-client", "rpc-client", "tokio"] }
6175
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "electrum", "time"] }
6276
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }
77+
#lightning-macros = { path = "../rust-lightning/lightning-macros" }
6378

6479
bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] }
6580
bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]}
@@ -78,11 +93,6 @@ rand = "0.8.5"
7893
chrono = { version = "0.4", default-features = false, features = ["clock"] }
7994
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
8095
esplora-client = { version = "0.12", default-features = false, features = ["tokio", "async-https-rustls"] }
81-
82-
# FIXME: This was introduced to decouple the `bdk_esplora` and
83-
# `lightning-transaction-sync` APIs. We should drop it as part of the upgrade
84-
# to LDK 0.2.
85-
esplora-client_0_11 = { package = "esplora-client", version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
8696
electrum-client = { version = "0.24.0", default-features = true }
8797
libc = "0.2"
8898
uniffi = { version = "0.28.3", features = ["build"], optional = true }
@@ -97,8 +107,9 @@ prost = { version = "0.11.6", default-features = false}
97107
winapi = { version = "0.3", features = ["winbase"] }
98108

99109
[dev-dependencies]
100-
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
110+
#lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
101111
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
112+
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "4e32d85249359d8ef8ece97d89848e40154363ab", features = ["std", "_test_utils"] }
102113
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
103114
proptest = "1.0.0"
104115
regex = "1.5.6"

bindings/ldk_node.udl

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dictionary Config {
1212
sequence<PublicKey> trusted_peers_0conf;
1313
u64 probing_liquidity_limit_multiplier;
1414
AnchorChannelsConfig? anchor_channels_config;
15-
SendingParameters? sending_parameters;
15+
RouteParametersConfig? route_parameters;
1616
};
1717

1818
dictionary AnchorChannelsConfig {
@@ -167,13 +167,13 @@ interface Bolt11InvoiceDescription {
167167

168168
interface Bolt11Payment {
169169
[Throws=NodeError]
170-
PaymentId send([ByRef]Bolt11Invoice invoice, SendingParameters? sending_parameters);
170+
PaymentId send([ByRef]Bolt11Invoice invoice, RouteParametersConfig? route_parameters);
171171
[Throws=NodeError]
172-
PaymentId send_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat, SendingParameters? sending_parameters);
172+
PaymentId send_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat, RouteParametersConfig? route_parameters);
173173
[Throws=NodeError]
174-
void send_probes([ByRef]Bolt11Invoice invoice);
174+
void send_probes([ByRef]Bolt11Invoice invoice, RouteParametersConfig? route_parameters);
175175
[Throws=NodeError]
176-
void send_probes_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat);
176+
void send_probes_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat, RouteParametersConfig? route_parameters);
177177
[Throws=NodeError]
178178
void claim_for_hash(PaymentHash payment_hash, u64 claimable_amount_msat, PaymentPreimage preimage);
179179
[Throws=NodeError]
@@ -213,13 +213,13 @@ interface Bolt12Payment {
213213

214214
interface SpontaneousPayment {
215215
[Throws=NodeError]
216-
PaymentId send(u64 amount_msat, PublicKey node_id, SendingParameters? sending_parameters);
216+
PaymentId send(u64 amount_msat, PublicKey node_id, RouteParametersConfig? route_parameters);
217217
[Throws=NodeError]
218-
PaymentId send_with_custom_tlvs(u64 amount_msat, PublicKey node_id, SendingParameters? sending_parameters, sequence<CustomTlvRecord> custom_tlvs);
218+
PaymentId send_with_custom_tlvs(u64 amount_msat, PublicKey node_id, RouteParametersConfig? route_parameters, sequence<CustomTlvRecord> custom_tlvs);
219219
[Throws=NodeError]
220-
PaymentId send_with_preimage(u64 amount_msat, PublicKey node_id, PaymentPreimage preimage, SendingParameters? sending_parameters);
220+
PaymentId send_with_preimage(u64 amount_msat, PublicKey node_id, PaymentPreimage preimage, RouteParametersConfig? route_parameters);
221221
[Throws=NodeError]
222-
PaymentId send_with_preimage_and_custom_tlvs(u64 amount_msat, PublicKey node_id, sequence<CustomTlvRecord> custom_tlvs, PaymentPreimage preimage, SendingParameters? sending_parameters);
222+
PaymentId send_with_preimage_and_custom_tlvs(u64 amount_msat, PublicKey node_id, sequence<CustomTlvRecord> custom_tlvs, PaymentPreimage preimage, RouteParametersConfig? route_parameters);
223223
[Throws=NodeError]
224224
void send_probes(u64 amount_msat, PublicKey node_id);
225225
};
@@ -254,7 +254,7 @@ interface LSPS1Liquidity {
254254
[Throws=NodeError]
255255
LSPS1OrderStatus request_channel(u64 lsp_balance_sat, u64 client_balance_sat, u32 channel_expiry_blocks, boolean announce_channel);
256256
[Throws=NodeError]
257-
LSPS1OrderStatus check_order_status(OrderId order_id);
257+
LSPS1OrderStatus check_order_status(LSPS1OrderId order_id);
258258
};
259259

260260
[Error]
@@ -392,7 +392,7 @@ enum PaymentFailureReason {
392392
[Enum]
393393
interface ClosureReason {
394394
CounterpartyForceClosed(UntrustedString peer_msg);
395-
HolderForceClosed(boolean? broadcasted_latest_txn);
395+
HolderForceClosed(boolean? broadcasted_latest_txn, string message);
396396
LegacyCooperativeClosure();
397397
CounterpartyInitiatedCooperativeClosure();
398398
LocallyInitiatedCooperativeClosure();
@@ -402,8 +402,9 @@ interface ClosureReason {
402402
DisconnectedPeer();
403403
OutdatedChannelManager();
404404
CounterpartyCoopClosedUnfundedChannel();
405+
LocallyCoopClosedUnfundedChannel();
405406
FundingBatchClosure();
406-
HTLCsTimedOut();
407+
HTLCsTimedOut( PaymentHash? payment_hash );
407408
PeerFeerateTooLow(u32 peer_feerate_sat_per_kw, u32 required_feerate_sat_per_kw);
408409
};
409410

@@ -456,11 +457,11 @@ dictionary PaymentDetails {
456457
u64 latest_update_timestamp;
457458
};
458459

459-
dictionary SendingParameters {
460-
MaxTotalRoutingFeeLimit? max_total_routing_fee_msat;
461-
u32? max_total_cltv_expiry_delta;
462-
u8? max_path_count;
463-
u8? max_channel_saturation_power_of_half;
460+
dictionary RouteParametersConfig {
461+
u64? max_total_routing_fee_msat;
462+
u32 max_total_cltv_expiry_delta;
463+
u8 max_path_count;
464+
u8 max_channel_saturation_power_of_half;
464465
};
465466

466467
dictionary CustomTlvRecord {
@@ -469,13 +470,13 @@ dictionary CustomTlvRecord {
469470
};
470471

471472
dictionary LSPS1OrderStatus {
472-
OrderId order_id;
473-
OrderParameters order_params;
474-
PaymentInfo payment_options;
475-
ChannelOrderInfo? channel_state;
473+
LSPS1OrderId order_id;
474+
LSPS1OrderParams order_params;
475+
LSPS1PaymentInfo payment_options;
476+
LSPS1ChannelInfo? channel_state;
476477
};
477478

478-
dictionary OrderParameters {
479+
dictionary LSPS1OrderParams {
479480
u64 lsp_balance_sat;
480481
u64 client_balance_sat;
481482
u16 required_channel_confirmations;
@@ -485,22 +486,22 @@ dictionary OrderParameters {
485486
boolean announce_channel;
486487
};
487488

488-
dictionary PaymentInfo {
489-
Bolt11PaymentInfo? bolt11;
490-
OnchainPaymentInfo? onchain;
489+
dictionary LSPS1PaymentInfo {
490+
LSPS1Bolt11PaymentInfo? bolt11;
491+
LSPS1OnchainPaymentInfo? onchain;
491492
};
492493

493-
dictionary Bolt11PaymentInfo {
494-
PaymentState state;
495-
DateTime expires_at;
494+
dictionary LSPS1Bolt11PaymentInfo {
495+
LSPS1PaymentState state;
496+
LSPSDateTime expires_at;
496497
u64 fee_total_sat;
497498
u64 order_total_sat;
498499
Bolt11Invoice invoice;
499500
};
500501

501-
dictionary OnchainPaymentInfo {
502-
PaymentState state;
503-
DateTime expires_at;
502+
dictionary LSPS1OnchainPaymentInfo {
503+
LSPS1PaymentState state;
504+
LSPSDateTime expires_at;
504505
u64 fee_total_sat;
505506
u64 order_total_sat;
506507
Address address;
@@ -509,24 +510,18 @@ dictionary OnchainPaymentInfo {
509510
Address? refund_onchain_address;
510511
};
511512

512-
dictionary ChannelOrderInfo {
513-
DateTime funded_at;
513+
dictionary LSPS1ChannelInfo {
514+
LSPSDateTime funded_at;
514515
OutPoint funding_outpoint;
515-
DateTime expires_at;
516+
LSPSDateTime expires_at;
516517
};
517518

518-
enum PaymentState {
519+
enum LSPS1PaymentState {
519520
"ExpectPayment",
520521
"Paid",
521522
"Refunded",
522523
};
523524

524-
[Enum]
525-
interface MaxTotalRoutingFeeLimit {
526-
None ();
527-
Some ( u64 amount_msat );
528-
};
529-
530525
[NonExhaustive]
531526
enum Network {
532527
"Bitcoin",
@@ -861,7 +856,7 @@ typedef string UntrustedString;
861856
typedef string NodeAlias;
862857

863858
[Custom]
864-
typedef string OrderId;
859+
typedef string LSPS1OrderId;
865860

866861
[Custom]
867-
typedef string DateTime;
862+
typedef string LSPSDateTime;

src/builder.rs

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use lightning::routing::router::DefaultRouter;
4848
use lightning::routing::scoring::{
4949
ProbabilisticScorer, ProbabilisticScoringDecayParameters, ProbabilisticScoringFeeParameters,
5050
};
51-
use lightning::sign::EntropySource;
51+
use lightning::sign::{EntropySource, NodeSigner};
5252

5353
use lightning::util::persist::{
5454
read_channel_monitors, CHANNEL_MANAGER_PERSISTENCE_KEY,
@@ -173,17 +173,17 @@ pub enum BuildError {
173173
RuntimeSetupFailed,
174174
/// We failed to read data from the [`KVStore`].
175175
///
176-
/// [`KVStore`]: lightning::util::persist::KVStore
176+
/// [`KVStore`]: lightning::util::persist::KVStoreSync
177177
ReadFailed,
178178
/// We failed to write data to the [`KVStore`].
179179
///
180-
/// [`KVStore`]: lightning::util::persist::KVStore
180+
/// [`KVStore`]: lightning::util::persist::KVStoreSync
181181
WriteFailed,
182182
/// We failed to access the given `storage_dir_path`.
183183
StoragePathAccessFailed,
184184
/// We failed to setup our [`KVStore`].
185185
///
186-
/// [`KVStore`]: lightning::util::persist::KVStore
186+
/// [`KVStore`]: lightning::util::persist::KVStoreSync
187187
KVStoreSetupFailed,
188188
/// We failed to setup the onchain wallet.
189189
WalletSetupFailed,
@@ -1275,15 +1275,6 @@ fn build_with_store_internal(
12751275
},
12761276
};
12771277

1278-
// Initialize the ChainMonitor
1279-
let chain_monitor: Arc<ChainMonitor> = Arc::new(chainmonitor::ChainMonitor::new(
1280-
Some(Arc::clone(&chain_source)),
1281-
Arc::clone(&tx_broadcaster),
1282-
Arc::clone(&logger),
1283-
Arc::clone(&fee_estimator),
1284-
Arc::clone(&kv_store),
1285-
));
1286-
12871278
// Initialize the KeysManager
12881279
let cur_time = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).map_err(|e| {
12891280
log_error!(logger, "Failed to get current time: {}", e);
@@ -1299,6 +1290,19 @@ fn build_with_store_internal(
12991290
Arc::clone(&logger),
13001291
));
13011292

1293+
let peer_storage_key = keys_manager.get_peer_storage_key();
1294+
1295+
// Initialize the ChainMonitor
1296+
let chain_monitor: Arc<ChainMonitor> = Arc::new(chainmonitor::ChainMonitor::new(
1297+
Some(Arc::clone(&chain_source)),
1298+
Arc::clone(&tx_broadcaster),
1299+
Arc::clone(&logger),
1300+
Arc::clone(&fee_estimator),
1301+
Arc::clone(&kv_store),
1302+
Arc::clone(&keys_manager),
1303+
peer_storage_key,
1304+
));
1305+
13021306
// Initialize the network graph, scorer, and router
13031307
let network_graph =
13041308
match io::utils::read_network_graph(Arc::clone(&kv_store), Arc::clone(&logger)) {
@@ -1359,17 +1363,6 @@ fn build_with_store_internal(
13591363
};
13601364

13611365
let mut user_config = default_user_config(&config);
1362-
if liquidity_source_config.and_then(|lsc| lsc.lsps2_client.as_ref()).is_some() {
1363-
// Generally allow claiming underpaying HTLCs as the LSP will skim off some fee. We'll
1364-
// check that they don't take too much before claiming.
1365-
user_config.channel_config.accept_underpaying_htlcs = true;
1366-
1367-
// FIXME: When we're an LSPS2 client, set maximum allowed inbound HTLC value in flight
1368-
// to 100%. We should eventually be able to set this on a per-channel basis, but for
1369-
// now we just bump the default for all channels.
1370-
user_config.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel =
1371-
100;
1372-
}
13731366

13741367
if liquidity_source_config.and_then(|lsc| lsc.lsps2_service.as_ref()).is_some() {
13751368
// If we act as an LSPS2 service, we need to to be able to intercept HTLCs and forward the
@@ -1447,8 +1440,8 @@ fn build_with_store_internal(
14471440

14481441
// Give ChannelMonitors to ChainMonitor
14491442
for (_blockhash, channel_monitor) in channel_monitors.into_iter() {
1450-
let funding_outpoint = channel_monitor.get_funding_txo().0;
1451-
chain_monitor.watch_channel(funding_outpoint, channel_monitor).map_err(|e| {
1443+
let channel_id = channel_monitor.channel_id();
1444+
chain_monitor.watch_channel(channel_id, channel_monitor).map_err(|e| {
14521445
log_error!(logger, "Failed to watch channel monitor: {:?}", e);
14531446
BuildError::InvalidChannelMonitor
14541447
})?;
@@ -1560,13 +1553,15 @@ fn build_with_store_internal(
15601553
as Arc<dyn RoutingMessageHandler + Sync + Send>,
15611554
onion_message_handler: Arc::clone(&onion_messenger),
15621555
custom_message_handler,
1556+
send_only_message_handler: Arc::clone(&chain_monitor),
15631557
},
15641558
GossipSync::Rapid(_) => MessageHandler {
15651559
chan_handler: Arc::clone(&channel_manager),
15661560
route_handler: Arc::new(IgnoringMessageHandler {})
15671561
as Arc<dyn RoutingMessageHandler + Sync + Send>,
15681562
onion_message_handler: Arc::clone(&onion_messenger),
15691563
custom_message_handler,
1564+
send_only_message_handler: Arc::clone(&chain_monitor),
15701565
},
15711566
GossipSync::None => {
15721567
unreachable!("We must always have a gossip sync!");
@@ -1611,7 +1606,7 @@ fn build_with_store_internal(
16111606
Ok(output_sweeper) => Arc::new(output_sweeper),
16121607
Err(e) => {
16131608
if e.kind() == std::io::ErrorKind::NotFound {
1614-
Arc::new(OutputSweeper::new(
1609+
Arc::new(OutputSweeper::new_with_kv_store_sync(
16151610
channel_manager.current_best_block(),
16161611
Arc::clone(&tx_broadcaster),
16171612
Arc::clone(&fee_estimator),

0 commit comments

Comments
 (0)