Skip to content

Commit 0ef635e

Browse files
committed
Move BOLT11 payments API to Bolt11PaymentHandler
1 parent 785543d commit 0ef635e

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
@@ -51,6 +51,7 @@ interface Node {
5151
void event_handled();
5252
PublicKey node_id();
5353
sequence<SocketAddress>? listening_addresses();
54+
Bolt11PaymentHandler bolt11_payment();
5455
[Throws=NodeError]
5556
Address new_onchain_address();
5657
[Throws=NodeError]
@@ -70,25 +71,9 @@ interface Node {
7071
[Throws=NodeError]
7172
void sync_wallets();
7273
[Throws=NodeError]
73-
PaymentHash send_payment([ByRef]Bolt11Invoice invoice);
74-
[Throws=NodeError]
75-
PaymentHash send_payment_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat);
76-
[Throws=NodeError]
7774
PaymentHash send_spontaneous_payment(u64 amount_msat, PublicKey node_id);
7875
[Throws=NodeError]
79-
void send_payment_probes([ByRef]Bolt11Invoice invoice);
80-
[Throws=NodeError]
8176
void send_spontaneous_payment_probes(u64 amount_msat, PublicKey node_id);
82-
[Throws=NodeError]
83-
void send_payment_probes_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat);
84-
[Throws=NodeError]
85-
Bolt11Invoice receive_payment(u64 amount_msat, [ByRef]string description, u32 expiry_secs);
86-
[Throws=NodeError]
87-
Bolt11Invoice receive_variable_amount_payment([ByRef]string description, u32 expiry_secs);
88-
[Throws=NodeError]
89-
Bolt11Invoice receive_payment_via_jit_channel(u64 amount_msat, [ByRef]string description, u32 expiry_secs, u64? max_lsp_fee_limit_msat);
90-
[Throws=NodeError]
91-
Bolt11Invoice receive_variable_amount_payment_via_jit_channel([ByRef]string description, u32 expiry_secs, u64? max_proportional_lsp_fee_limit_ppm_msat);
9277
PaymentDetails? payment([ByRef]PaymentHash payment_hash);
9378
[Throws=NodeError]
9479
void remove_payment([ByRef]PaymentHash payment_hash);
@@ -102,6 +87,25 @@ interface Node {
10287
boolean is_running();
10388
};
10489

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