Skip to content

Commit eea1fcd

Browse files
committed
Move BOLT11 payments API to Bolt11PaymentHandler
1 parent e781c08 commit eea1fcd

File tree

11 files changed

+602
-505
lines changed

11 files changed

+602
-505
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A ready-to-go Lightning node library built using [LDK][ldk] and [BDK][bdk].
1111
LDK Node is a self-custodial Lightning node in library form. Its central goal is to provide a small, simple, and straightforward interface that enables users to easily set up and run a Lightning node with an integrated on-chain wallet. While minimalism is at its core, LDK Node aims to be sufficiently modular and configurable to be useful for a variety of use cases.
1212

1313
## Getting Started
14-
The primary abstraction of the library is the [`Node`][api_docs_node], which can be retrieved by setting up and configuring a [`Builder`][api_docs_builder] to your liking and calling one of the `build` methods. `Node` can then be controlled via commands such as `start`, `stop`, `connect_open_channel`, `send_payment`, etc.
14+
The primary abstraction of the library is the [`Node`][api_docs_node], which can be retrieved by setting up and configuring a [`Builder`][api_docs_builder] to your liking and calling one of the `build` methods. `Node` can then be controlled via commands such as `start`, `stop`, `connect_open_channel`, `send`, etc.
1515

1616
```rust
1717
use ldk_node::Builder;
@@ -44,7 +44,7 @@ fn main() {
4444
node.event_handled();
4545

4646
let invoice = Bolt11Invoice::from_str("INVOICE_STR").unwrap();
47-
node.send_payment(&invoice).unwrap();
47+
node.bolt11_payment().send(&invoice).unwrap();
4848

4949
node.stop().unwrap();
5050
}

bindings/kotlin/ldk-node-jvm/lib/src/test/kotlin/org/lightningdevkit/ldknode/LibraryTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ class LibraryTest {
222222
else -> return
223223
}
224224

225-
val invoice = node2.receivePayment(2500000u, "asdf", 9217u)
225+
val invoice = node2.bolt11Payment().receive(2500000u, "asdf", 9217u)
226226

227-
node1.sendPayment(invoice)
227+
node1.bolt11Payment().send(invoice)
228228

229229
val paymentSuccessfulEvent = node1.waitNextEvent()
230230
println("Got event: $paymentSuccessfulEvent")

bindings/ldk_node.udl

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ interface Node {
5353
void event_handled();
5454
PublicKey node_id();
5555
sequence<SocketAddress>? listening_addresses();
56+
Bolt11PaymentHandler bolt11_payment();
5657
[Throws=NodeError]
5758
Address new_onchain_address();
5859
[Throws=NodeError]
@@ -72,25 +73,9 @@ interface Node {
7273
[Throws=NodeError]
7374
void sync_wallets();
7475
[Throws=NodeError]
75-
PaymentHash send_payment([ByRef]Bolt11Invoice invoice);
76-
[Throws=NodeError]
77-
PaymentHash send_payment_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat);
78-
[Throws=NodeError]
7976
PaymentHash send_spontaneous_payment(u64 amount_msat, PublicKey node_id);
8077
[Throws=NodeError]
81-
void send_payment_probes([ByRef]Bolt11Invoice invoice);
82-
[Throws=NodeError]
8378
void send_spontaneous_payment_probes(u64 amount_msat, PublicKey node_id);
84-
[Throws=NodeError]
85-
void send_payment_probes_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat);
86-
[Throws=NodeError]
87-
Bolt11Invoice receive_payment(u64 amount_msat, [ByRef]string description, u32 expiry_secs);
88-
[Throws=NodeError]
89-
Bolt11Invoice receive_variable_amount_payment([ByRef]string description, u32 expiry_secs);
90-
[Throws=NodeError]
91-
Bolt11Invoice receive_payment_via_jit_channel(u64 amount_msat, [ByRef]string description, u32 expiry_secs, u64? max_lsp_fee_limit_msat);
92-
[Throws=NodeError]
93-
Bolt11Invoice receive_variable_amount_payment_via_jit_channel([ByRef]string description, u32 expiry_secs, u64? max_proportional_lsp_fee_limit_ppm_msat);
9479
PaymentDetails? payment([ByRef]PaymentHash payment_hash);
9580
[Throws=NodeError]
9681
void remove_payment([ByRef]PaymentHash payment_hash);
@@ -103,6 +88,25 @@ interface Node {
10388
boolean verify_signature([ByRef]sequence<u8> msg, [ByRef]string sig, [ByRef]PublicKey pkey);
10489
};
10590

91+
interface Bolt11PaymentHandler {
92+
[Throws=NodeError]
93+
PaymentHash send([ByRef]Bolt11Invoice invoice);
94+
[Throws=NodeError]
95+
PaymentHash send_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat);
96+
[Throws=NodeError]
97+
void send_probes([ByRef]Bolt11Invoice invoice);
98+
[Throws=NodeError]
99+
void send_probes_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat);
100+
[Throws=NodeError]
101+
Bolt11Invoice receive(u64 amount_msat, [ByRef]string description, u32 expiry_secs);
102+
[Throws=NodeError]
103+
Bolt11Invoice receive_variable_amount([ByRef]string description, u32 expiry_secs);
104+
[Throws=NodeError]
105+
Bolt11Invoice receive_via_jit_channel(u64 amount_msat, [ByRef]string description, u32 expiry_secs, u64? max_lsp_fee_limit_msat);
106+
[Throws=NodeError]
107+
Bolt11Invoice receive_variable_amount_via_jit_channel([ByRef]string description, u32 expiry_secs, u64? max_proportional_lsp_fee_limit_ppm_msat);
108+
};
109+
106110
[Error]
107111
enum NodeError {
108112
"AlreadyRunning",

bindings/python/src/ldk_node/test_ldk_node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ def test_channel_full_cycle(self):
185185
print("EVENT:", channel_ready_event_2)
186186
node_2.event_handled()
187187

188-
invoice = node_2.receive_payment(2500000, "asdf", 9217)
189-
node_1.send_payment(invoice)
188+
invoice = node_2.bolt11_payment().receive(2500000, "asdf", 9217)
189+
node_1.bolt11_payment().send(invoice)
190190

191191
payment_successful_event_1 = node_1.wait_next_event()
192192
assert isinstance(payment_successful_event_1, Event.PAYMENT_SUCCESSFUL)

0 commit comments

Comments
 (0)