diff --git a/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveWalletTest.kt b/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveWalletTest.kt index 6b6b5b9..b9a7d54 100644 --- a/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveWalletTest.kt +++ b/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveWalletTest.kt @@ -19,6 +19,15 @@ class LiveWalletTest { println("Balance: $balance") assert(wallet.getBalance().total > 0uL) + + println("Transactions count: ${wallet.transactions().count()}") + val transactions = wallet.transactions().take(3) + for (tx in transactions) { + val sentAndReceived = wallet.sentAndReceived(tx) + println("Transaction: ${tx.txid()}") + println("Sent ${sentAndReceived.sent}") + println("Received ${sentAndReceived.received}") + } } @Test diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index e141421..1fe1ed9 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -109,6 +109,8 @@ interface Wallet { boolean sign(PartiallySignedTransaction psbt); SentAndReceivedValues sent_and_received([ByRef] Transaction tx); + + sequence transactions(); }; interface Update {}; diff --git a/bdk-ffi/src/wallet.rs b/bdk-ffi/src/wallet.rs index 4ede1d7..3cb1eb0 100644 --- a/bdk-ffi/src/wallet.rs +++ b/bdk-ffi/src/wallet.rs @@ -99,6 +99,13 @@ impl Wallet { let (sent, received): (u64, u64) = self.get_wallet().sent_and_received(&tx.clone().into()); SentAndReceivedValues { sent, received } } + + pub fn transactions(&self) -> Vec> { + self.get_wallet() + .transactions() + .map(|tx| Arc::new(tx.tx_node.tx.clone().into())) + .collect() + } } pub struct SentAndReceivedValues { diff --git a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveWalletTest.kt b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveWalletTest.kt index ff709f8..dda5b9f 100644 --- a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveWalletTest.kt +++ b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveWalletTest.kt @@ -15,6 +15,15 @@ class LiveWalletTest { println("Balance: ${wallet.getBalance().total}") assert(wallet.getBalance().total > 0uL) + + println("Transactions count: ${wallet.transactions().count()}") + val transactions = wallet.transactions().take(3) + for (tx in transactions) { + val sentAndReceived = wallet.sentAndReceived(tx) + println("Transaction: ${tx.txid()}") + println("Sent ${sentAndReceived.sent}") + println("Received ${sentAndReceived.received}") + } } @Test diff --git a/bdk-python/tests/test_live_wallet.py b/bdk-python/tests/test_live_wallet.py index 922fada..c04f8e9 100644 --- a/bdk-python/tests/test_live_wallet.py +++ b/bdk-python/tests/test_live_wallet.py @@ -5,7 +5,7 @@ class TestLiveWallet(unittest.TestCase): def test_synced_balance(self): descriptor: bdk.Descriptor = bdk.Descriptor( - "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", bdk.Network.TESTNET ) wallet: bdk.Wallet = bdk.Wallet.new_no_persist( @@ -23,6 +23,15 @@ class TestLiveWallet(unittest.TestCase): self.assertGreater(wallet.get_balance().total, 0) + print(f"Transactions count: {len(wallet.transactions())}") + transactions = wallet.transactions()[:3] + for tx in transactions: + sent_and_received = wallet.sent_and_received(tx) + print(f"Transaction: {tx.txid()}") + print(f"Sent {sent_and_received.sent}") + print(f"Received {sent_and_received.received}") + + def test_broadcast_transaction(self): descriptor: bdk.Descriptor = bdk.Descriptor( "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", diff --git a/bdk-swift/Tests/BitcoinDevKitTests/LiveWalletTests.swift b/bdk-swift/Tests/BitcoinDevKitTests/LiveWalletTests.swift index 8756598..b936ea9 100644 --- a/bdk-swift/Tests/BitcoinDevKitTests/LiveWalletTests.swift +++ b/bdk-swift/Tests/BitcoinDevKitTests/LiveWalletTests.swift @@ -21,6 +21,15 @@ final class LiveWalletTests: XCTestCase { try wallet.applyUpdate(update: update) XCTAssertGreaterThan(wallet.getBalance().total, UInt64(0)) + + print("Transactions count: \(wallet.transactions().count)") + let transactions = wallet.transactions().prefix(3) + for tx in transactions { + let sentAndReceived = wallet.sentAndReceived(tx: tx) + print("Transaction: \(tx.txid())") + print("Sent \(sentAndReceived.sent)") + print("Received \(sentAndReceived.received)") + } } func testBroadcastTransaction() throws {