ldk-node 0.7.0

A ready-to-go node implementation built using LDK.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
namespace ldk_node {
	Mnemonic generate_entropy_mnemonic(WordCount? word_count);
	Config default_config();
};

dictionary Config {
	string storage_dir_path;
	Network network;
	sequence<SocketAddress>? listening_addresses;
	sequence<SocketAddress>? announcement_addresses;
	NodeAlias? node_alias;
	sequence<PublicKey> trusted_peers_0conf;
	u64 probing_liquidity_limit_multiplier;
	AnchorChannelsConfig? anchor_channels_config;
	RouteParametersConfig? route_parameters;
};

dictionary AnchorChannelsConfig {
	sequence<PublicKey> trusted_peers_no_reserve;
	u64 per_channel_reserve_sats;
};

dictionary BackgroundSyncConfig {
	u64 onchain_wallet_sync_interval_secs;
	u64 lightning_wallet_sync_interval_secs;
	u64 fee_rate_cache_update_interval_secs;
};

dictionary EsploraSyncConfig {
	BackgroundSyncConfig? background_sync_config;
};

dictionary ElectrumSyncConfig {
	BackgroundSyncConfig? background_sync_config;
};

dictionary LSPS2ServiceConfig {
	string? require_token;
	boolean advertise_service;
	u32 channel_opening_fee_ppm;
	u32 channel_over_provisioning_ppm;
	u64 min_channel_opening_fee_msat;
	u32 min_channel_lifetime;
	u32 max_client_to_self_delay;
	u64 min_payment_size_msat;
	u64 max_payment_size_msat;
	boolean client_trusts_lsp;
};

enum WordCount {
	"Words12",
	"Words15",
	"Words18",
	"Words21",
	"Words24",
};

enum LogLevel {
	"Gossip",
	"Trace",
	"Debug",
	"Info",
	"Warn",
	"Error",
};

dictionary LogRecord {
	LogLevel level;
	string args;
	string module_path;
	u32 line;
};

[Trait, WithForeign]
interface LogWriter {
	void log(LogRecord record);
};

interface Builder {
	constructor();
	[Name=from_config]
	constructor(Config config);
	void set_entropy_seed_path(string seed_path);
	[Throws=BuildError]
	void set_entropy_seed_bytes(sequence<u8> seed_bytes);
	void set_entropy_bip39_mnemonic(Mnemonic mnemonic, string? passphrase);
	void set_chain_source_esplora(string server_url, EsploraSyncConfig? config);
	void set_chain_source_electrum(string server_url, ElectrumSyncConfig? config);
	void set_chain_source_bitcoind_rpc(string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
	void set_chain_source_bitcoind_rest(string rest_host, u16 rest_port, string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
	void set_gossip_source_p2p();
	void set_gossip_source_rgs(string rgs_server_url);
	void set_pathfinding_scores_source(string url);
	void set_liquidity_source_lsps1(PublicKey node_id, SocketAddress address, string? token);
	void set_liquidity_source_lsps2(PublicKey node_id, SocketAddress address, string? token);
	void set_storage_dir_path(string storage_dir_path);
	void set_filesystem_logger(string? log_file_path, LogLevel? max_log_level);
	void set_log_facade_logger();
	void set_custom_logger(LogWriter log_writer);
	void set_network(Network network);
	[Throws=BuildError]
	void set_listening_addresses(sequence<SocketAddress> listening_addresses);
	[Throws=BuildError]
	void set_announcement_addresses(sequence<SocketAddress> announcement_addresses);
	[Throws=BuildError]
	void set_node_alias(string node_alias);
	[Throws=BuildError]
	void set_async_payments_role(AsyncPaymentsRole? role);
	[Throws=BuildError]
	Node build();
	[Throws=BuildError]
	Node build_with_fs_store();
	[Throws=BuildError]
	Node build_with_vss_store(string vss_url, string store_id, string lnurl_auth_server_url, record<string, string> fixed_headers);
	[Throws=BuildError]
	Node build_with_vss_store_and_fixed_headers(string vss_url, string store_id, record<string, string> fixed_headers);
	[Throws=BuildError]
	Node build_with_vss_store_and_header_provider(string vss_url, string store_id, VssHeaderProvider header_provider);
};

interface Node {
	[Throws=NodeError]
	void start();
	[Throws=NodeError]
	void stop();
	NodeStatus status();
	Config config();
	Event? next_event();
	Event wait_next_event();
	[Async]
	Event next_event_async();
	[Throws=NodeError]
	void event_handled();
	PublicKey node_id();
	sequence<SocketAddress>? listening_addresses();
	sequence<SocketAddress>? announcement_addresses();
	NodeAlias? node_alias();
	Bolt11Payment bolt11_payment();
	Bolt12Payment bolt12_payment();
	SpontaneousPayment spontaneous_payment();
	OnchainPayment onchain_payment();
	UnifiedQrPayment unified_qr_payment();
	LSPS1Liquidity lsps1_liquidity();
	[Throws=NodeError]
	void connect(PublicKey node_id, SocketAddress address, boolean persist);
	[Throws=NodeError]
	void disconnect(PublicKey node_id);
	[Throws=NodeError]
	UserChannelId open_channel(PublicKey node_id, SocketAddress address, u64 channel_amount_sats, u64? push_to_counterparty_msat, ChannelConfig? channel_config);
	[Throws=NodeError]
	UserChannelId open_announced_channel(PublicKey node_id, SocketAddress address, u64 channel_amount_sats, u64? push_to_counterparty_msat, ChannelConfig? channel_config);
	[Throws=NodeError]
	void splice_in([ByRef]UserChannelId user_channel_id, PublicKey counterparty_node_id, u64 splice_amount_sats);
	[Throws=NodeError]
	void splice_out([ByRef]UserChannelId user_channel_id, PublicKey counterparty_node_id, [ByRef]Address address, u64 splice_amount_sats);
	[Throws=NodeError]
	void close_channel([ByRef]UserChannelId user_channel_id, PublicKey counterparty_node_id);
	[Throws=NodeError]
	void force_close_channel([ByRef]UserChannelId user_channel_id, PublicKey counterparty_node_id, string? reason);
	[Throws=NodeError]
	void update_channel_config([ByRef]UserChannelId user_channel_id, PublicKey counterparty_node_id, ChannelConfig channel_config);
	[Throws=NodeError]
	void sync_wallets();
	PaymentDetails? payment([ByRef]PaymentId payment_id);
	[Throws=NodeError]
	void remove_payment([ByRef]PaymentId payment_id);
	BalanceDetails list_balances();
	sequence<PaymentDetails> list_payments();
	sequence<PeerDetails> list_peers();
	sequence<ChannelDetails> list_channels();
	NetworkGraph network_graph();
	string sign_message([ByRef]sequence<u8> msg);
	boolean verify_signature([ByRef]sequence<u8> msg, [ByRef]string sig, [ByRef]PublicKey pkey);
	[Throws=NodeError]
	bytes export_pathfinding_scores();
};

[Enum]
interface Bolt11InvoiceDescription {
	Hash(string hash);
	Direct(string description);
};

interface Bolt11Payment {
	[Throws=NodeError]
	PaymentId send([ByRef]Bolt11Invoice invoice, RouteParametersConfig? route_parameters);
	[Throws=NodeError]
	PaymentId send_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat, RouteParametersConfig? route_parameters);
	[Throws=NodeError]
	void send_probes([ByRef]Bolt11Invoice invoice, RouteParametersConfig? route_parameters);
	[Throws=NodeError]
	void send_probes_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat, RouteParametersConfig? route_parameters);
	[Throws=NodeError]
	void claim_for_hash(PaymentHash payment_hash, u64 claimable_amount_msat, PaymentPreimage preimage);
	[Throws=NodeError]
	void fail_for_hash(PaymentHash payment_hash);
	[Throws=NodeError]
	Bolt11Invoice receive(u64 amount_msat, [ByRef]Bolt11InvoiceDescription description, u32 expiry_secs);
	[Throws=NodeError]
	Bolt11Invoice receive_for_hash(u64 amount_msat, [ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, PaymentHash payment_hash);
	[Throws=NodeError]
	Bolt11Invoice receive_variable_amount([ByRef]Bolt11InvoiceDescription description, u32 expiry_secs);
	[Throws=NodeError]
	Bolt11Invoice receive_variable_amount_for_hash([ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, PaymentHash payment_hash);
	[Throws=NodeError]
	Bolt11Invoice receive_via_jit_channel(u64 amount_msat, [ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, u64? max_lsp_fee_limit_msat);
	[Throws=NodeError]
	Bolt11Invoice receive_via_jit_channel_for_hash(u64 amount_msat, [ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, u64? max_lsp_fee_limit_msat, PaymentHash payment_hash);
	[Throws=NodeError]
	Bolt11Invoice receive_variable_amount_via_jit_channel([ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, u64? max_proportional_lsp_fee_limit_ppm_msat);
	[Throws=NodeError]
	Bolt11Invoice receive_variable_amount_via_jit_channel_for_hash([ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, u64? max_proportional_lsp_fee_limit_ppm_msat, PaymentHash payment_hash);
};

interface Bolt12Payment {
	[Throws=NodeError]
	PaymentId send([ByRef]Offer offer, u64? quantity, string? payer_note, RouteParametersConfig? route_parameters);
	[Throws=NodeError]
	PaymentId send_using_amount([ByRef]Offer offer, u64 amount_msat, u64? quantity, string? payer_note, RouteParametersConfig? route_parameters);
	[Throws=NodeError]
	Offer receive(u64 amount_msat, [ByRef]string description, u32? expiry_secs, u64? quantity);
	[Throws=NodeError]
	Offer receive_variable_amount([ByRef]string description, u32? expiry_secs);
	[Throws=NodeError]
	Bolt12Invoice request_refund_payment([ByRef]Refund refund);
	[Throws=NodeError]
	Refund initiate_refund(u64 amount_msat, u32 expiry_secs, u64? quantity, string? payer_note, RouteParametersConfig? route_parameters);
	[Throws=NodeError]
	Offer receive_async();
	[Throws=NodeError]
	void set_paths_to_static_invoice_server(bytes paths);
	[Throws=NodeError]
	bytes blinded_paths_for_async_recipient(bytes recipient_id);
};

interface SpontaneousPayment {
	[Throws=NodeError]
	PaymentId send(u64 amount_msat, PublicKey node_id, RouteParametersConfig? route_parameters);
	[Throws=NodeError]
	PaymentId send_with_custom_tlvs(u64 amount_msat, PublicKey node_id, RouteParametersConfig? route_parameters, sequence<CustomTlvRecord> custom_tlvs);
	[Throws=NodeError]
	PaymentId send_with_preimage(u64 amount_msat, PublicKey node_id, PaymentPreimage preimage, RouteParametersConfig? route_parameters);
	[Throws=NodeError]
	PaymentId send_with_preimage_and_custom_tlvs(u64 amount_msat, PublicKey node_id, sequence<CustomTlvRecord> custom_tlvs, PaymentPreimage preimage, RouteParametersConfig? route_parameters);
	[Throws=NodeError]
	void send_probes(u64 amount_msat, PublicKey node_id);
};

interface OnchainPayment {
	[Throws=NodeError]
	Address new_address();
	[Throws=NodeError]
	Txid send_to_address([ByRef]Address address, u64 amount_sats, FeeRate? fee_rate);
	[Throws=NodeError]
	Txid send_all_to_address([ByRef]Address address, boolean retain_reserve, FeeRate? fee_rate);
};

interface FeeRate {
	[Name=from_sat_per_kwu]
	constructor(u64 sat_kwu);
	[Name=from_sat_per_vb_unchecked]
	constructor(u64 sat_vb);
	u64 to_sat_per_kwu();
	u64 to_sat_per_vb_floor();
	u64 to_sat_per_vb_ceil();
};

interface UnifiedQrPayment {
	[Throws=NodeError]
	string receive(u64 amount_sats, [ByRef]string message, u32 expiry_sec);
	[Throws=NodeError]
	QrPaymentResult send([ByRef]string uri_str, RouteParametersConfig? route_parameters);
};

interface LSPS1Liquidity {
	[Throws=NodeError]
	LSPS1OrderStatus request_channel(u64 lsp_balance_sat, u64 client_balance_sat, u32 channel_expiry_blocks, boolean announce_channel);
	[Throws=NodeError]
	LSPS1OrderStatus check_order_status(LSPS1OrderId order_id);
};

[Error]
enum NodeError {
	"AlreadyRunning",
	"NotRunning",
	"OnchainTxCreationFailed",
	"ConnectionFailed",
	"InvoiceCreationFailed",
	"InvoiceRequestCreationFailed",
	"OfferCreationFailed",
	"RefundCreationFailed",
	"PaymentSendingFailed",
	"InvalidCustomTlvs",
	"ProbeSendingFailed",
	"ChannelCreationFailed",
	"ChannelClosingFailed",
	"ChannelSplicingFailed",
	"ChannelConfigUpdateFailed",
	"PersistenceFailed",
	"FeerateEstimationUpdateFailed",
	"FeerateEstimationUpdateTimeout",
	"WalletOperationFailed",
	"WalletOperationTimeout",
	"OnchainTxSigningFailed",
	"TxSyncFailed",
	"TxSyncTimeout",
	"GossipUpdateFailed",
	"GossipUpdateTimeout",
	"LiquidityRequestFailed",
	"UriParameterParsingFailed",
	"InvalidAddress",
	"InvalidSocketAddress",
	"InvalidPublicKey",
	"InvalidSecretKey",
	"InvalidOfferId",
	"InvalidNodeId",
	"InvalidPaymentId",
	"InvalidPaymentHash",
	"InvalidPaymentPreimage",
	"InvalidPaymentSecret",
	"InvalidAmount",
	"InvalidInvoice",
	"InvalidOffer",
	"InvalidRefund",
	"InvalidChannelId",
	"InvalidNetwork",
	"InvalidUri",
	"InvalidQuantity",
	"InvalidNodeAlias",
	"InvalidDateTime",
	"InvalidFeeRate",
	"DuplicatePayment",
	"UnsupportedCurrency",
	"InsufficientFunds",
	"LiquiditySourceUnavailable",
	"LiquidityFeeTooHigh",
	"InvalidBlindedPaths",
	"AsyncPaymentServicesDisabled",
};

dictionary NodeStatus {
	boolean is_running;
	BestBlock current_best_block;
	u64? latest_lightning_wallet_sync_timestamp;
	u64? latest_onchain_wallet_sync_timestamp;
	u64? latest_fee_rate_cache_update_timestamp;
	u64? latest_rgs_snapshot_timestamp;
	u64? latest_pathfinding_scores_sync_timestamp;
	u64? latest_node_announcement_broadcast_timestamp;
	u32? latest_channel_monitor_archival_height;
};

dictionary BestBlock {
	BlockHash block_hash;
	u32 height;
};

[Error]
enum BuildError {
	"InvalidSeedBytes",
	"InvalidSeedFile",
	"InvalidSystemTime",
	"InvalidChannelMonitor",
	"InvalidListeningAddresses",
	"InvalidAnnouncementAddresses",
	"InvalidNodeAlias",
	"RuntimeSetupFailed",
	"ReadFailed",
	"WriteFailed",
	"StoragePathAccessFailed",
	"KVStoreSetupFailed",
	"WalletSetupFailed",
	"LoggerSetupFailed",
	"NetworkMismatch",
	"AsyncPaymentsConfigMismatch",
};

[Trait]
interface VssHeaderProvider {
	[Async, Throws=VssHeaderProviderError]
	record<string, string> get_headers([ByRef]sequence<u8> request);
};

[Error]
enum VssHeaderProviderError {
	"InvalidData",
	"RequestError",
	"AuthorizationError",
	"InternalError",
};

[Enum]
interface Event {
	PaymentSuccessful(PaymentId? payment_id, PaymentHash payment_hash, PaymentPreimage? payment_preimage, u64? fee_paid_msat);
	PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
	PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat, sequence<CustomTlvRecord> custom_records);
	PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline, sequence<CustomTlvRecord> custom_records);
	PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
	prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
	ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
	ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, OutPoint? funding_txo);
	ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
	SplicePending(ChannelId channel_id, UserChannelId user_channel_id, PublicKey counterparty_node_id, OutPoint new_funding_txo);
	SpliceFailed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey counterparty_node_id, OutPoint? abandoned_funding_txo);
};

enum PaymentFailureReason {
	"RecipientRejected",
	"UserAbandoned",
	"RetriesExhausted",
	"PaymentExpired",
	"RouteNotFound",
	"UnexpectedError",
	"UnknownRequiredFeatures",
	"InvoiceRequestExpired",
	"InvoiceRequestRejected",
	"BlindedPathCreationFailed",
};

[Enum]
interface ClosureReason {
	CounterpartyForceClosed(UntrustedString peer_msg);
	HolderForceClosed(boolean? broadcasted_latest_txn, string message);
	LegacyCooperativeClosure();
	CounterpartyInitiatedCooperativeClosure();
	LocallyInitiatedCooperativeClosure();
	CommitmentTxConfirmed();
	FundingTimedOut();
	ProcessingError(string err);
	DisconnectedPeer();
	OutdatedChannelManager();
	CounterpartyCoopClosedUnfundedChannel();
	LocallyCoopClosedUnfundedChannel();
	FundingBatchClosure();
	HTLCsTimedOut( PaymentHash? payment_hash );
	PeerFeerateTooLow(u32 peer_feerate_sat_per_kw, u32 required_feerate_sat_per_kw);
};

[Enum]
interface PaymentKind {
	Onchain(Txid txid, ConfirmationStatus status);
	Bolt11(PaymentHash hash, PaymentPreimage? preimage, PaymentSecret? secret);
	Bolt11Jit(PaymentHash hash, PaymentPreimage? preimage, PaymentSecret? secret, u64? counterparty_skimmed_fee_msat, LSPFeeLimits lsp_fee_limits);
	Bolt12Offer(PaymentHash? hash, PaymentPreimage? preimage, PaymentSecret? secret, OfferId offer_id, UntrustedString? payer_note, u64? quantity);
	Bolt12Refund(PaymentHash? hash, PaymentPreimage? preimage, PaymentSecret? secret, UntrustedString? payer_note, u64? quantity);
	Spontaneous(PaymentHash hash, PaymentPreimage? preimage);
};

[Enum]
interface QrPaymentResult {
	Onchain(Txid txid);
	Bolt11(PaymentId payment_id);
	Bolt12(PaymentId payment_id);
};

enum PaymentDirection {
	"Inbound",
	"Outbound",
};

enum PaymentStatus {
	"Pending",
	"Succeeded",
	"Failed",
};

dictionary LSPFeeLimits {
	u64? max_total_opening_fee_msat;
	u64? max_proportional_opening_fee_ppm_msat;
};

[Enum]
interface ConfirmationStatus {
	Confirmed (BlockHash block_hash, u32 height, u64 timestamp);
	Unconfirmed ();
};

dictionary PaymentDetails {
	PaymentId id;
	PaymentKind kind;
	u64? amount_msat;
	u64? fee_paid_msat;
	PaymentDirection direction;
	PaymentStatus status;
	u64 latest_update_timestamp;
};

dictionary RouteParametersConfig {
	u64? max_total_routing_fee_msat;
	u32 max_total_cltv_expiry_delta;
	u8 max_path_count;
	u8 max_channel_saturation_power_of_half;
};

dictionary CustomTlvRecord {
	u64 type_num;
	sequence<u8> value;
};

dictionary LSPS1OrderStatus {
	LSPS1OrderId order_id;
	LSPS1OrderParams order_params;
	LSPS1PaymentInfo payment_options;
	LSPS1ChannelInfo? channel_state;
};

dictionary LSPS1OrderParams {
	u64 lsp_balance_sat;
	u64 client_balance_sat;
	u16 required_channel_confirmations;
	u16 funding_confirms_within_blocks;
	u32 channel_expiry_blocks;
	string? token;
	boolean announce_channel;
};

dictionary LSPS1PaymentInfo {
	LSPS1Bolt11PaymentInfo? bolt11;
	LSPS1OnchainPaymentInfo? onchain;
};

dictionary LSPS1Bolt11PaymentInfo {
	LSPS1PaymentState state;
	LSPSDateTime expires_at;
	u64 fee_total_sat;
	u64 order_total_sat;
	Bolt11Invoice invoice;
};

dictionary LSPS1OnchainPaymentInfo {
	LSPS1PaymentState state;
	LSPSDateTime expires_at;
	u64 fee_total_sat;
	u64 order_total_sat;
	Address address;
	u16? min_onchain_payment_confirmations;
	FeeRate min_fee_for_0conf;
	Address? refund_onchain_address;
};

dictionary LSPS1ChannelInfo {
	LSPSDateTime funded_at;
	OutPoint funding_outpoint;
	LSPSDateTime expires_at;
};

enum LSPS1PaymentState {
	"ExpectPayment",
	"Paid",
	"Refunded",
};

[NonExhaustive]
enum Network {
	"Bitcoin",
	"Testnet",
	"Signet",
	"Regtest",
};

dictionary OutPoint {
	Txid txid;
	u32 vout;
};

dictionary ChannelDetails {
	ChannelId channel_id;
	PublicKey counterparty_node_id;
	OutPoint? funding_txo;
	u64? short_channel_id;
	u64? outbound_scid_alias;
	u64? inbound_scid_alias;
	u64 channel_value_sats;
	u64? unspendable_punishment_reserve;
	UserChannelId user_channel_id;
	u32 feerate_sat_per_1000_weight;
	u64 outbound_capacity_msat;
	u64 inbound_capacity_msat;
	u32? confirmations_required;
	u32? confirmations;
	boolean is_outbound;
	boolean is_channel_ready;
	boolean is_usable;
	boolean is_announced;
	u16? cltv_expiry_delta;
	u64 counterparty_unspendable_punishment_reserve;
	u64? counterparty_outbound_htlc_minimum_msat;
	u64? counterparty_outbound_htlc_maximum_msat;
	u32? counterparty_forwarding_info_fee_base_msat;
	u32? counterparty_forwarding_info_fee_proportional_millionths;
	u16? counterparty_forwarding_info_cltv_expiry_delta;
	u64 next_outbound_htlc_limit_msat;
	u64 next_outbound_htlc_minimum_msat;
	u16? force_close_spend_delay;
	u64 inbound_htlc_minimum_msat;
	u64? inbound_htlc_maximum_msat;
	ChannelConfig config;
};

dictionary PeerDetails {
	PublicKey node_id;
	SocketAddress address;
	boolean is_persisted;
	boolean is_connected;
};

[Enum]
interface LightningBalance {
	ClaimableOnChannelClose (
		ChannelId channel_id,
		PublicKey counterparty_node_id,
		u64 amount_satoshis,
		u64 transaction_fee_satoshis,
		u64 outbound_payment_htlc_rounded_msat,
		u64 outbound_forwarded_htlc_rounded_msat,
		u64 inbound_claiming_htlc_rounded_msat,
		u64 inbound_htlc_rounded_msat
	);
	ClaimableAwaitingConfirmations (
		ChannelId channel_id,
		PublicKey counterparty_node_id,
		u64 amount_satoshis,
		u32 confirmation_height,
		BalanceSource source
	);
	ContentiousClaimable (
		ChannelId channel_id,
		PublicKey counterparty_node_id,
		u64 amount_satoshis,
		u32 timeout_height,
		PaymentHash payment_hash,
		PaymentPreimage payment_preimage
	);
	MaybeTimeoutClaimableHTLC (
		ChannelId channel_id,
		PublicKey counterparty_node_id,
		u64 amount_satoshis,
		u32 claimable_height,
		PaymentHash payment_hash,
		boolean outbound_payment
	);
	MaybePreimageClaimableHTLC (
		ChannelId channel_id,
		PublicKey counterparty_node_id,
		u64 amount_satoshis,
		u32 expiry_height,
		PaymentHash payment_hash
	);
	CounterpartyRevokedOutputClaimable (
		ChannelId channel_id,
		PublicKey counterparty_node_id,
		u64 amount_satoshis
	);
};

enum BalanceSource {
	"HolderForceClosed",
	"CounterpartyForceClosed",
	"CoopClose",
	"Htlc",
};

[Enum]
interface PendingSweepBalance {
	PendingBroadcast ( ChannelId? channel_id, u64 amount_satoshis );
	BroadcastAwaitingConfirmation ( ChannelId? channel_id, u32 latest_broadcast_height, Txid latest_spending_txid, u64 amount_satoshis );
	AwaitingThresholdConfirmations ( ChannelId? channel_id, Txid latest_spending_txid, BlockHash confirmation_hash, u32 confirmation_height, u64 amount_satoshis);
};

dictionary BalanceDetails {
	u64 total_onchain_balance_sats;
	u64 spendable_onchain_balance_sats;
	u64 total_anchor_channels_reserve_sats;
	u64 total_lightning_balance_sats;
	sequence<LightningBalance> lightning_balances;
	sequence<PendingSweepBalance> pending_balances_from_channel_closures;
};

dictionary ChannelConfig {
	u32 forwarding_fee_proportional_millionths;
	u32 forwarding_fee_base_msat;
	u16 cltv_expiry_delta;
	MaxDustHTLCExposure max_dust_htlc_exposure;
	u64 force_close_avoidance_max_fee_satoshis;
	boolean accept_underpaying_htlcs;
};

[Enum]
interface MaxDustHTLCExposure {
	FixedLimit ( u64 limit_msat );
	FeeRateMultiplier ( u64 multiplier );
};

interface NetworkGraph {
	sequence<u64> list_channels();
	ChannelInfo? channel(u64 short_channel_id);
	sequence<NodeId> list_nodes();
	NodeInfo? node([ByRef]NodeId node_id);
};

dictionary ChannelInfo {
	NodeId node_one;
	ChannelUpdateInfo? one_to_two;
	NodeId node_two;
	ChannelUpdateInfo? two_to_one;
	u64? capacity_sats;
};

dictionary ChannelUpdateInfo {
	u32 last_update;
	boolean enabled;
	u16 cltv_expiry_delta;
	u64 htlc_minimum_msat;
	u64 htlc_maximum_msat;
	RoutingFees fees;
};

dictionary RoutingFees {
	u32 base_msat;
	u32 proportional_millionths;
};

dictionary NodeInfo {
	sequence<u64> channels;
	NodeAnnouncementInfo? announcement_info;
};

dictionary NodeAnnouncementInfo {
	u32 last_update;
	string alias;
	sequence<SocketAddress> addresses;
};

enum Currency {
	"Bitcoin",
	"BitcoinTestnet",
	"Regtest",
	"Simnet",
	"Signet",
};

enum AsyncPaymentsRole {
	"Client",
	"Server",
};

dictionary RouteHintHop {
	PublicKey src_node_id;
	u64 short_channel_id;
	u16 cltv_expiry_delta;
	u64? htlc_minimum_msat;
	u64? htlc_maximum_msat;
	RoutingFees fees;
};

[Traits=(Debug, Display, Eq)]
interface Bolt11Invoice {
	[Throws=NodeError, Name=from_str]
	constructor([ByRef] string invoice_str);
	sequence<u8> signable_hash();
	PaymentHash payment_hash();
	PaymentSecret payment_secret();
	u64? amount_milli_satoshis();
	u64 expiry_time_seconds();
	u64 seconds_since_epoch();
	u64 seconds_until_expiry();
	boolean is_expired();
	boolean would_expire(u64 at_time_seconds);
	Bolt11InvoiceDescription invoice_description();
	u64 min_final_cltv_expiry_delta();
	Network network();
	Currency currency();
	sequence<Address> fallback_addresses();
	sequence<sequence<RouteHintHop>> route_hints();
	PublicKey recover_payee_pub_key();
};

[Enum]
interface OfferAmount {
	Bitcoin(u64 amount_msats);
	Currency(string iso4217_code, u64 amount);
};

[Traits=(Debug, Display, Eq)]
interface Offer {
	[Throws=NodeError, Name=from_str]
	constructor([ByRef] string offer_str);
	OfferId id();
	boolean is_expired();
	string? offer_description();
	string? issuer();
	OfferAmount? amount();
	boolean is_valid_quantity(u64 quantity);
	boolean expects_quantity();
	boolean supports_chain(Network chain);
	sequence<Network> chains();
	sequence<u8>? metadata();
	u64? absolute_expiry_seconds();
	PublicKey? issuer_signing_pubkey();
};

[Traits=(Debug, Display, Eq)]
interface Refund {
	[Throws=NodeError, Name=from_str]
	constructor([ByRef] string refund_str);
	string refund_description();
	u64? absolute_expiry_seconds();
	boolean is_expired();
	string? issuer();
	sequence<u8> payer_metadata();
	Network? chain();
	u64 amount_msats();
	u64? quantity();
	PublicKey payer_signing_pubkey();
	string? payer_note();
};

interface Bolt12Invoice {
	[Throws=NodeError, Name=from_str]
	constructor([ByRef] string invoice_str);
	PaymentHash payment_hash();
	u64 amount_msats();
	OfferAmount? amount();
	PublicKey signing_pubkey();
	u64 created_at();
	u64? absolute_expiry_seconds();
	u64 relative_expiry();
	boolean is_expired();
	string? invoice_description();
	string? issuer();
	string? payer_note();
	sequence<u8>? metadata();
	u64? quantity();
	sequence<u8> signable_hash();
	PublicKey payer_signing_pubkey();
	PublicKey? issuer_signing_pubkey();
	sequence<u8> chain();
	sequence<sequence<u8>>? offer_chains();
	sequence<Address> fallback_addresses();
	sequence<u8> encode();
};

[Custom]
typedef string Txid;

[Custom]
typedef string BlockHash;

[Custom]
typedef string SocketAddress;

[Custom]
typedef string PublicKey;

[Custom]
typedef string NodeId;

[Custom]
typedef string Address;

[Custom]
typedef string OfferId;

[Custom]
typedef string PaymentId;

[Custom]
typedef string PaymentHash;

[Custom]
typedef string PaymentPreimage;

[Custom]
typedef string PaymentSecret;

[Custom]
typedef string ChannelId;

[Custom]
typedef string UserChannelId;

[Custom]
typedef string Mnemonic;

[Custom]
typedef string UntrustedString;

[Custom]
typedef string NodeAlias;

[Custom]
typedef string LSPS1OrderId;

[Custom]
typedef string LSPSDateTime;