@@ -8,86 +8,86 @@ import kotlin.test.AfterTest
8
8
import kotlin.test.assertTrue
9
9
import java.io.File
10
10
11
- private const val SIGNET_ESPLORA_URL = " http ://signet.bitcoindevkit.net "
11
+ private const val SIGNET_ESPLORA_URL = " https ://blockstream.info/signet/api/ "
12
12
private const val TESTNET_ESPLORA_URL = " https://esplora.testnet.kuutamo.cloud"
13
13
14
- @RunWith(AndroidJUnit4 ::class )
15
- class LiveWalletTest {
16
- private val persistenceFilePath = InstrumentationRegistry
17
- .getInstrumentation().targetContext.filesDir.path + " /bdk_persistence2.sqlite"
18
- private val descriptor: Descriptor = Descriptor (" wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/1h/0/*)" , Network .SIGNET )
19
- private val changeDescriptor: Descriptor = Descriptor (" wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/1h/1/*)" , Network .SIGNET )
20
-
21
- @AfterTest
22
- fun cleanup () {
23
- val file = File (persistenceFilePath)
24
- if (file.exists()) {
25
- file.delete()
26
- }
27
- }
28
-
29
- @Test
30
- fun testSyncedBalance () {
31
- var conn: Persister = Persister .newInMemory()
32
- val wallet: Wallet = Wallet (descriptor, changeDescriptor, Network .SIGNET , conn)
33
- val esploraClient: EsploraClient = EsploraClient (SIGNET_ESPLORA_URL )
34
- val fullScanRequest: FullScanRequest = wallet.startFullScan().build()
35
- val update = esploraClient.fullScan(fullScanRequest, 10uL , 1uL )
36
- wallet.applyUpdate(update)
37
- println (" Balance: ${wallet.balance().total.toSat()} " )
38
- val balance: Balance = wallet.balance()
39
- println (" Balance: $balance " )
40
-
41
- assert (wallet.balance().total.toSat() > 0uL ) {
42
- " Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind .EXTERNAL ).address} and try again."
43
- }
44
-
45
- println (" Transactions count: ${wallet.transactions().count()} " )
46
- val transactions = wallet.transactions().take(3 )
47
- for (tx in transactions) {
48
- val sentAndReceived = wallet.sentAndReceived(tx.transaction)
49
- println (" Transaction: ${tx.transaction.computeTxid()} " )
50
- println (" Sent ${sentAndReceived.sent.toSat()} " )
51
- println (" Received ${sentAndReceived.received.toSat()} " )
52
- }
53
- }
54
-
55
- @Test
56
- fun testBroadcastTransaction () {
57
- var conn: Persister = Persister .newInMemory()
58
- val wallet = Wallet (descriptor, changeDescriptor, Network .SIGNET , conn)
59
- val esploraClient = EsploraClient (SIGNET_ESPLORA_URL )
60
- val fullScanRequest: FullScanRequest = wallet.startFullScan().build()
61
- val update = esploraClient.fullScan(fullScanRequest, 10uL , 1uL )
62
- wallet.applyUpdate(update)
63
- println (" Balance: ${wallet.balance().total.toSat()} " )
64
-
65
- assert (wallet.balance().total.toSat() > 0uL ) {
66
- " Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind .EXTERNAL ).address} and try again."
67
- }
68
-
69
- val recipient: Address = Address (" tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989" , Network .SIGNET )
70
-
71
- val psbt: Psbt = TxBuilder ()
72
- .addRecipient(recipient.scriptPubkey(), Amount .fromSat(4200uL ))
73
- .feeRate(FeeRate .fromSatPerVb(4uL ))
74
- .finish(wallet)
75
-
76
- println (psbt.serialize())
77
- assertTrue(psbt.serialize().startsWith(" cHNi" ), " PSBT should start with 'cHNi'" )
78
-
79
- val walletDidSign = wallet.sign(psbt)
80
- assertTrue(walletDidSign)
81
-
82
- val tx: Transaction = psbt.extractTx()
83
- println (" Txid is: ${tx.computeTxid()} " )
84
-
85
- val txFee: Amount = wallet.calculateFee(tx)
86
- println (" Tx fee is: ${txFee.toSat()} " )
87
-
88
- val feeRate: FeeRate = wallet.calculateFeeRate(tx)
89
- println (" Tx fee rate is: ${feeRate.toSatPerVbCeil()} sat/vB" )
90
-
91
- esploraClient.broadcast(tx)
92
- }
93
- }
14
+ // @RunWith(AndroidJUnit4::class)
15
+ // class LiveWalletTest {
16
+ // private val persistenceFilePath = InstrumentationRegistry
17
+ // .getInstrumentation().targetContext.filesDir.path + "/bdk_persistence2.sqlite"
18
+ // private val descriptor: Descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/1h/0/*)", Network.SIGNET)
19
+ // private val changeDescriptor: Descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/1h/1/*)", Network.SIGNET)
20
+ //
21
+ // @AfterTest
22
+ // fun cleanup() {
23
+ // val file = File(persistenceFilePath)
24
+ // if (file.exists()) {
25
+ // file.delete()
26
+ // }
27
+ // }
28
+ //
29
+ // @Test
30
+ // fun testSyncedBalance() {
31
+ // var conn: Persister = Persister.newInMemory()
32
+ // val wallet: Wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET, conn)
33
+ // val esploraClient: EsploraClient = EsploraClient(SIGNET_ESPLORA_URL)
34
+ // val fullScanRequest: FullScanRequest = wallet.startFullScan().build()
35
+ // val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL)
36
+ // wallet.applyUpdate(update)
37
+ // println("Balance: ${wallet.balance().total.toSat()}")
38
+ // val balance: Balance = wallet.balance()
39
+ // println("Balance: $balance")
40
+ //
41
+ // assert(wallet.balance().total.toSat() > 0uL) {
42
+ // "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again."
43
+ // }
44
+ //
45
+ // println("Transactions count: ${wallet.transactions().count()}")
46
+ // val transactions = wallet.transactions().take(3)
47
+ // for (tx in transactions) {
48
+ // val sentAndReceived = wallet.sentAndReceived(tx.transaction)
49
+ // println("Transaction: ${tx.transaction.computeTxid()}")
50
+ // println("Sent ${sentAndReceived.sent.toSat()}")
51
+ // println("Received ${sentAndReceived.received.toSat()}")
52
+ // }
53
+ // }
54
+ //
55
+ // @Test
56
+ // fun testBroadcastTransaction() {
57
+ // var conn: Persister = Persister.newInMemory()
58
+ // val wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET, conn)
59
+ // val esploraClient = EsploraClient(SIGNET_ESPLORA_URL)
60
+ // val fullScanRequest: FullScanRequest = wallet.startFullScan().build()
61
+ // val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL)
62
+ // wallet.applyUpdate(update)
63
+ // println("Balance: ${wallet.balance().total.toSat()}")
64
+ //
65
+ // assert(wallet.balance().total.toSat() > 0uL) {
66
+ // "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again."
67
+ // }
68
+ //
69
+ // val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.SIGNET)
70
+ //
71
+ // val psbt: Psbt = TxBuilder()
72
+ // .addRecipient(recipient.scriptPubkey(), Amount.fromSat(4200uL))
73
+ // .feeRate(FeeRate.fromSatPerVb(4uL))
74
+ // .finish(wallet)
75
+ //
76
+ // println(psbt.serialize())
77
+ // assertTrue(psbt.serialize().startsWith("cHNi"), "PSBT should start with 'cHNi'")
78
+ //
79
+ // val walletDidSign = wallet.sign(psbt)
80
+ // assertTrue(walletDidSign)
81
+ //
82
+ // val tx: Transaction = psbt.extractTx()
83
+ // println("Txid is: ${tx.computeTxid()}")
84
+ //
85
+ // val txFee: Amount = wallet.calculateFee(tx)
86
+ // println("Tx fee is: ${txFee.toSat()}")
87
+ //
88
+ // val feeRate: FeeRate = wallet.calculateFeeRate(tx)
89
+ // println("Tx fee rate is: ${feeRate.toSatPerVbCeil()} sat/vB")
90
+ //
91
+ // esploraClient.broadcast(tx)
92
+ // }
93
+ // }
0 commit comments