Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LSPS2 service-side support #420

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ lightning-background-processor = { version = "0.0.125", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.125" }
lightning-block-sync = { version = "0.0.125", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.0.125", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }
#lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }
lightning-liquidity = { git = "https://github.com/tnull/lightning-liquidity", branch="2024-07-update-lsps1", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std"] }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
Expand Down
75 changes: 74 additions & 1 deletion bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ interface Builder {
void set_chain_source_bitcoind_rpc(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_liquidity_source_lsps2(SocketAddress address, PublicKey node_id, string? token);
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_network(Network network);
[Throws=BuildError]
Expand Down Expand Up @@ -78,6 +79,7 @@ interface Node {
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]
Expand Down Expand Up @@ -173,6 +175,13 @@ interface UnifiedQrPayment {
QrPaymentResult send([ByRef]string uri_str);
};

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(OrderId order_id);
};

[Error]
enum NodeError {
"AlreadyRunning",
Expand Down Expand Up @@ -220,6 +229,8 @@ enum NodeError {
"InvalidUri",
"InvalidQuantity",
"InvalidNodeAlias",
"InvalidDateTime",
"InvalidFeeRate",
"DuplicatePayment",
"UnsupportedCurrency",
"InsufficientFunds",
Expand Down Expand Up @@ -370,6 +381,59 @@ dictionary CustomTlvRecord {
sequence<u8> value;
};

dictionary LSPS1OrderStatus {
OrderId order_id;
OrderParameters order_params;
PaymentInfo payment_options;
ChannelOrderInfo? channel_state;
};

dictionary OrderParameters {
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 PaymentInfo {
Bolt11PaymentInfo? bolt11;
OnchainPaymentInfo? onchain;
};

dictionary Bolt11PaymentInfo {
PaymentState state;
DateTime expires_at;
u64 fee_total_sat;
u64 order_total_sat;
Bolt11Invoice invoice;
};

dictionary OnchainPaymentInfo {
PaymentState state;
DateTime 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 ChannelOrderInfo {
DateTime funded_at;
OutPoint funding_outpoint;
DateTime expires_at;
};

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

[Enum]
interface MaxTotalRoutingFeeLimit {
None ();
Expand Down Expand Up @@ -622,3 +686,12 @@ typedef string UntrustedString;

[Custom]
typedef string NodeAlias;

[Custom]
typedef string OrderId;

[Custom]
typedef string DateTime;

[Custom]
typedef string FeeRate;
Loading
Loading