Add jvm walletTxBuilderDrainWallet test
This commit is contained in:
parent
65b9a3f9b6
commit
1905d8804d
@ -136,8 +136,7 @@ class JvmLibTest {
|
|||||||
assertNotNull(txid)
|
assertNotNull(txid)
|
||||||
} else {
|
} else {
|
||||||
val depositAddress = wallet.getLastUnusedAddress()
|
val depositAddress = wallet.getLastUnusedAddress()
|
||||||
println("Send more testnet coins to: $depositAddress")
|
fail("Send more testnet coins to: $depositAddress")
|
||||||
fail()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,4 +149,27 @@ class JvmLibTest {
|
|||||||
txBuilder.build(wallet)
|
txBuilder.build(wallet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun walletTxBuilderDrainWallet() {
|
||||||
|
val descriptor =
|
||||||
|
"wpkh([8da6afbe/84'/1'/0'/0]tprv8hY7jbMbe17EH1cLw2feTyNDYvjcFYauLmbneBqVnDERBrV51LrxWjCYRZwWS5keYn3ijb7iHJuEzXQk7EzgPeKRBVNBgC4oFPDxGND5S3V/*)"
|
||||||
|
val wallet = Wallet(descriptor, null, Network.TESTNET, databaseConfig, blockchainConfig)
|
||||||
|
wallet.sync(LogProgress(), null)
|
||||||
|
val balance = wallet.getBalance()
|
||||||
|
if (balance > 2000u) {
|
||||||
|
println("balance $balance")
|
||||||
|
// send all coins back to https://bitcoinfaucet.uo1.net
|
||||||
|
val faucetAddress = "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt"
|
||||||
|
val txBuilder = TxBuilder().drainWallet().drainTo(faucetAddress).feeRate(1.1f)
|
||||||
|
val psbt = txBuilder.build(wallet)
|
||||||
|
wallet.sign(psbt)
|
||||||
|
val txid = wallet.broadcast(psbt)
|
||||||
|
println("https://mempool.space/testnet/tx/$txid")
|
||||||
|
assertNotNull(txid)
|
||||||
|
} else {
|
||||||
|
val depositAddress = wallet.getLastUnusedAddress()
|
||||||
|
fail("Send more testnet coins to: $depositAddress")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user