Apply formatting
This commit is contained in:
parent
50dc701ec4
commit
b47c3c482d
@ -1,30 +1,37 @@
|
||||
import uniffi.bdk.*
|
||||
|
||||
class LogProgress: BdkProgress {
|
||||
override fun update(progress: Float, message: String? ) {
|
||||
class LogProgress : BdkProgress {
|
||||
override fun update(progress: Float, message: String?) {
|
||||
println("Syncing..")
|
||||
}
|
||||
}
|
||||
|
||||
class NullProgress: BdkProgress {
|
||||
override fun update(progress: Float, message: String? ) {
|
||||
|
||||
}
|
||||
class NullProgress : BdkProgress {
|
||||
override fun update(progress: Float, message: String?) {}
|
||||
}
|
||||
|
||||
fun getConfirmedTransaction(wallet: OnlineWalletInterface, transactionId: String): ConfirmedTransaction? {
|
||||
fun getConfirmedTransaction(
|
||||
wallet: OnlineWalletInterface,
|
||||
transactionId: String
|
||||
): ConfirmedTransaction? {
|
||||
wallet.sync(NullProgress(), null)
|
||||
return wallet.getTransactions().stream().filter({ it.id.equals(transactionId) }).findFirst().orElse(null)
|
||||
return wallet.getTransactions()
|
||||
.stream()
|
||||
.filter({ it.id.equals(transactionId) })
|
||||
.findFirst()
|
||||
.orElse(null)
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println("Configuring an in-memory wallet on electrum..")
|
||||
val descriptor =
|
||||
"pkh(cSQPHDBwXGjVzWRqAHm6zfvQhaTuj1f2bFH58h55ghbjtFwvmeXR)";
|
||||
val amount = 1000uL;
|
||||
val recipient = "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt";
|
||||
val descriptor = "pkh(cSQPHDBwXGjVzWRqAHm6zfvQhaTuj1f2bFH58h55ghbjtFwvmeXR)"
|
||||
val amount = 1000uL
|
||||
val recipient = "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt"
|
||||
val db = DatabaseConfig.Memory("")
|
||||
val client = BlockchainConfig.Electrum(ElectrumConfig("ssl://electrum.blockstream.info:60002", null, 5u, null, 10u))
|
||||
val client =
|
||||
BlockchainConfig.Electrum(
|
||||
ElectrumConfig("ssl://electrum.blockstream.info:60002", null, 5u, null, 10u)
|
||||
)
|
||||
val wallet = OnlineWallet(descriptor, Network.TESTNET, db, client)
|
||||
wallet.sync(LogProgress(), null)
|
||||
println("Initial wallet balance: ${wallet.getBalance()}")
|
||||
@ -34,7 +41,9 @@ fun main(args: Array<String>) {
|
||||
println("New wallet balance: ${wallet.getBalance()}")
|
||||
println("Press Enter to return funds")
|
||||
readLine()
|
||||
println("Creating a partially signed bitcoin transaction with recipient $recipient and amount $amount satoshis...")
|
||||
println(
|
||||
"Creating a PSBT with recipient $recipient and amount $amount satoshis..."
|
||||
)
|
||||
val transaction = PartiallySignedBitcoinTransaction(wallet, recipient, amount)
|
||||
println("Signing the transaction...")
|
||||
wallet.sign(transaction)
|
||||
@ -43,7 +52,7 @@ fun main(args: Array<String>) {
|
||||
println("Refunded $amount satoshis to $recipient via transaction id $transactionId")
|
||||
println("Confirming transaction...")
|
||||
var confirmedTransaction = getConfirmedTransaction(wallet, transactionId)
|
||||
while(confirmedTransaction == null) {
|
||||
while (confirmedTransaction == null) {
|
||||
confirmedTransaction = getConfirmedTransaction(wallet, transactionId)
|
||||
}
|
||||
println("Confirmed transaction: $confirmedTransaction")
|
||||
|
Loading…
x
Reference in New Issue
Block a user