refactor: restructure balance

This commit is contained in:
Matthew
2023-11-15 15:57:02 -06:00
parent e5ded1a726
commit 05ce7dad31
15 changed files with 54 additions and 71 deletions

View File

@@ -14,9 +14,9 @@ class LiveTxBuilderTest {
val esploraClient = EsploraClient("https://mempool.space/testnet/api")
val update = esploraClient.scan(wallet, 10uL, 1uL)
wallet.applyUpdate(update)
println("Balance: ${wallet.getBalance().total()}")
println("Balance: ${wallet.getBalance().total}")
assert(wallet.getBalance().total() > 0uL)
assert(wallet.getBalance().total > 0uL)
val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.TESTNET)
val psbt: PartiallySignedTransaction = TxBuilder()

View File

@@ -12,14 +12,13 @@ class LiveWalletTest {
val descriptor: Descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET)
val wallet: Wallet = Wallet.newNoPersist(descriptor, null, Network.TESTNET)
val esploraClient: EsploraClient = EsploraClient("https://mempool.space/testnet/api")
// val esploraClient = EsploraClient("https://blockstream.info/testnet/api")
val update = esploraClient.scan(wallet, 10uL, 1uL)
wallet.applyUpdate(update)
println("Balance: ${wallet.getBalance().total()}")
println("Balance: ${wallet.getBalance().total}")
val balance: Balance = wallet.getBalance()
println("Balance: $balance")
assert(wallet.getBalance().total() > 0uL)
assert(wallet.getBalance().total > 0uL)
}
@Test
@@ -30,10 +29,10 @@ class LiveWalletTest {
val update = esploraClient.scan(wallet, 10uL, 1uL)
wallet.applyUpdate(update)
println("Balance: ${wallet.getBalance().total()}")
println("Balance: ${wallet.getBalance().total}")
println("New address: ${wallet.getAddress(AddressIndex.New).address}")
assert(wallet.getBalance().total() > 0uL) {
assert(wallet.getBalance().total > 0uL) {
"Wallet balance must be greater than 0! Please send funds to ${wallet.getAddress(AddressIndex.New).address} and try again."
}

View File

@@ -50,7 +50,7 @@ class OfflineWalletTest {
assertEquals(
expected = 0uL,
actual = wallet.getBalance().total()
actual = wallet.getBalance().total
)
}
}