Skip to content

Commit 806f799

Browse files
committed
Expose list_payments in bindings
1 parent 64cf5f1 commit 806f799

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ class LibraryTest {
181181
assert(paymentReceivedEvent is Event.PaymentReceived)
182182
node2.eventHandled()
183183

184+
assert(node1.listPayments().size == 1)
185+
assert(node2.listPayments().size == 1)
186+
184187
node2.closeChannel(channelId, nodeId1)
185188

186189
val channelClosedEvent1 = node1.waitNextEvent()
@@ -196,7 +199,7 @@ class LibraryTest {
196199
mine(1u)
197200

198201
// Sleep a bit to allow for the block to propagate to esplora
199-
Thread.sleep(3_000)
202+
Thread.sleep(5_000)
200203

201204
node1.syncWallets()
202205
node2.syncWallets()

bindings/ldk_node.udl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ interface LDKNode {
6767
PaymentDetails? payment([ByRef]PaymentHash payment_hash);
6868
[Throws=NodeError]
6969
boolean remove_payment([ByRef]PaymentHash payment_hash);
70+
sequence<PaymentDetails> list_payments();
7071
sequence<PeerDetails> list_peers();
7172
sequence<ChannelDetails> list_channels();
7273
[Throws=NodeError]

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,11 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
17281728
self.payment_store.list_filter(f)
17291729
}
17301730

1731+
/// Retrieves all payments.
1732+
pub fn list_payments(&self) -> Vec<PaymentDetails> {
1733+
self.payment_store.list_filter(|_| true)
1734+
}
1735+
17311736
/// Retrieves a list of known peers.
17321737
pub fn list_peers(&self) -> Vec<PeerDetails> {
17331738
let active_connected_peers: Vec<PublicKey> =

src/test/functional_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ fn channel_full_cycle() {
106106
let payment_hash = node_a.send_payment(&invoice).unwrap();
107107
assert_eq!(node_a.send_payment(&invoice), Err(Error::DuplicatePayment));
108108

109+
assert_eq!(node_a.list_payments().first().unwrap().hash, payment_hash);
110+
109111
let outbound_payments_a =
110112
node_a.list_payments_with_filter(|p| p.direction == PaymentDirection::Outbound);
111113
assert_eq!(outbound_payments_a.len(), 1);

0 commit comments

Comments
 (0)