Skip to content

Commit b0ff3c8

Browse files
committed
Expose list_payments in bindings
1 parent cc2f5aa commit b0ff3c8

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
@@ -182,6 +182,9 @@ class LibraryTest {
182182
assert(paymentReceivedEvent is Event.PaymentReceived)
183183
node2.eventHandled()
184184

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

187190
val channelClosedEvent1 = node1.nextEvent()
@@ -197,7 +200,7 @@ class LibraryTest {
197200
mine(1u)
198201

199202
// Sleep a bit to allow for the block to propagate to esplora
200-
Thread.sleep(3_000)
203+
Thread.sleep(5_000)
201204

202205
node1.syncWallets()
203206
node2.syncWallets()

bindings/ldk_node.udl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ interface Node {
5858
PaymentDetails? payment([ByRef]PaymentHash payment_hash);
5959
[Throws=NodeError]
6060
boolean remove_payment([ByRef]PaymentHash payment_hash);
61+
sequence<PaymentDetails> list_payments();
6162
sequence<PeerDetails> list_peers();
6263
sequence<ChannelDetails> list_channels();
6364
};

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,11 @@ impl Node {
14641464
self.payment_store.list_filter(f)
14651465
}
14661466

1467+
/// Retrieves all payments.
1468+
pub fn list_payments(&self) -> Vec<PaymentDetails> {
1469+
self.payment_store.list_filter(|_| true)
1470+
}
1471+
14671472
/// Retrieves a list of known peers.
14681473
pub fn list_peers(&self) -> Vec<PeerDetails> {
14691474
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
@@ -97,6 +97,8 @@ fn channel_full_cycle() {
9797
let payment_hash = node_a.send_payment(&invoice).unwrap();
9898
assert_eq!(node_a.send_payment(&invoice), Err(Error::DuplicatePayment));
9999

100+
assert_eq!(node_a.list_payments().first().unwrap().hash, payment_hash);
101+
100102
let outbound_payments_a =
101103
node_a.list_payments_with_filter(|p| p.direction == PaymentDirection::Outbound);
102104
assert_eq!(outbound_payments_a.len(), 1);

0 commit comments

Comments
 (0)