namespace ldk_node {
};
dictionary Config {
string storage_dir_path;
Network network;
NetAddress? listening_address;
u32 default_cltv_expiry_delta;
u64 onchain_wallet_sync_interval_secs;
u64 wallet_sync_interval_secs;
u64 fee_rate_cache_update_interval_secs;
LogLevel log_level;
};
interface Builder {
constructor();
[Name=from_config]
constructor(Config config);
void set_entropy_seed_path(string seed_path);
void set_entropy_seed_bytes(sequence<u8> seed_bytes);
void set_entropy_bip39_mnemonic(Mnemonic mnemonic, string? passphrase);
void set_esplora_server(string esplora_server_url);
void set_gossip_source_p2p();
void set_gossip_source_rgs(string rgs_server_url);
void set_storage_dir_path(string storage_dir_path);
void set_network(Network network);
void set_listening_address(NetAddress listening_address);
LDKNode build();
};
interface LDKNode {
[Throws=NodeError]
void start();
[Throws=NodeError]
void stop();
Event? next_event();
Event wait_next_event();
void event_handled();
PublicKey node_id();
NetAddress? listening_address();
[Throws=NodeError]
Address new_funding_address();
[Throws=NodeError]
Txid send_to_onchain_address([ByRef]Address address, u64 amount_msat);
[Throws=NodeError]
Txid send_all_to_onchain_address([ByRef]Address address);
[Throws=NodeError]
u64 spendable_onchain_balance_sats();
[Throws=NodeError]
u64 total_onchain_balance_sats();
[Throws=NodeError]
void connect(PublicKey node_id, NetAddress address, boolean permanently);
[Throws=NodeError]
void disconnect(PublicKey node_id);
[Throws=NodeError]
void connect_open_channel(PublicKey node_id, NetAddress address, u64 channel_amount_sats, u64? push_to_counterparty_msat, boolean announce_channel);
[Throws=NodeError]
void close_channel([ByRef]ChannelId channel_id, PublicKey counterparty_node_id);
[Throws=NodeError]
void sync_wallets();
[Throws=NodeError]
PaymentHash send_payment([ByRef]Invoice invoice);
[Throws=NodeError]
PaymentHash send_payment_using_amount([ByRef]Invoice invoice, u64 amount_msat);
[Throws=NodeError]
PaymentHash send_spontaneous_payment(u64 amount_msat, PublicKey node_id);
[Throws=NodeError]
Invoice receive_payment(u64 amount_msat, [ByRef]string description, u32 expiry_secs);
[Throws=NodeError]
Invoice receive_variable_amount_payment([ByRef]string description, u32 expiry_secs);
PaymentDetails? payment([ByRef]PaymentHash payment_hash);
[Throws=NodeError]
boolean remove_payment([ByRef]PaymentHash payment_hash);
sequence<PaymentDetails> list_payments();
sequence<PeerDetails> list_peers();
sequence<ChannelDetails> list_channels();
[Throws=NodeError]
string sign_message([ByRef]sequence<u8> msg);
boolean verify_signature([ByRef]sequence<u8> msg, [ByRef]string sig, [ByRef]PublicKey pkey);
};
[Error]
enum NodeError {
"AlreadyRunning",
"NotRunning",
"OnchainTxCreationFailed",
"ConnectionFailed",
"InvoiceCreationFailed",
"PaymentSendingFailed",
"ChannelCreationFailed",
"ChannelClosingFailed",
"PersistenceFailed",
"WalletOperationFailed",
"OnchainTxSigningFailed",
"MessageSigningFailed",
"TxSyncFailed",
"GossipUpdateFailed",
"InvalidAddress",
"InvalidNetAddress",
"InvalidPublicKey",
"InvalidSecretKey",
"InvalidPaymentHash",
"InvalidPaymentPreimage",
"InvalidPaymentSecret",
"InvalidAmount",
"InvalidInvoice",
"InvalidChannelId",
"InvalidNetwork",
"DuplicatePayment",
"InsufficientFunds",
};
[Enum]
interface Event {
PaymentSuccessful( PaymentHash payment_hash );
PaymentFailed( PaymentHash payment_hash );
PaymentReceived( PaymentHash payment_hash, u64 amount_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 );
ChannelClosed ( ChannelId channel_id, UserChannelId user_channel_id );
};
enum PaymentDirection {
"Inbound",
"Outbound",
};
enum PaymentStatus {
"Pending",
"SendingFailed",
"Succeeded",
"Failed",
};
enum Network {
"Bitcoin",
"Testnet",
"Signet",
"Regtest",
};
dictionary PaymentDetails {
PaymentHash hash;
PaymentPreimage? preimage;
PaymentSecret? secret;
u64? amount_msat;
PaymentDirection direction;
PaymentStatus status;
};
dictionary OutPoint {
Txid txid;
u32 vout;
};
dictionary ChannelDetails {
ChannelId channel_id;
PublicKey counterparty_node_id;
OutPoint? funding_txo;
u64 channel_value_satoshis;
u64? unspendable_punishment_reserve;
UserChannelId user_channel_id;
u32 feerate_sat_per_1000_weight;
u64 balance_msat;
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_public;
u16? cltv_expiry_delta;
};
dictionary PeerDetails {
PublicKey node_id;
NetAddress address;
boolean is_connected;
};
enum LogLevel {
"Gossip",
"Trace",
"Debug",
"Info",
"Warn",
"Error",
};
[Custom]
typedef string Txid;
[Custom]
typedef string NetAddress;
[Custom]
typedef string PublicKey;
[Custom]
typedef string Address;
[Custom]
typedef string Invoice;
[Custom]
typedef string PaymentHash;
[Custom]
typedef string PaymentPreimage;
[Custom]
typedef string PaymentSecret;
[Custom]
typedef string ChannelId;
[Custom]
typedef string UserChannelId;
[Custom]
typedef string Mnemonic;