-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13c751c
commit 6e3025e
Showing
19 changed files
with
295 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,4 @@ jobs: | |
- name: "Run JVM tests" | ||
run: | | ||
cd bdk-jvm | ||
./gradlew test | ||
./gradlew test -P excludeConnectedTests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveTxBuilderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.bitcoindevkit | ||
|
||
import org.junit.Test | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class LiveTxBuilderTest { | ||
@Test | ||
fun testTxBuilder() { | ||
val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET) | ||
val wallet = Wallet.newNoPersist(descriptor, null, Network.TESTNET) | ||
val esploraClient = EsploraClient("https://mempool.space/testnet/api") | ||
val update = esploraClient.scan(wallet, 10uL, 1uL) | ||
wallet.applyUpdate(update) | ||
println("Balance: ${wallet.getBalance().total()}") | ||
|
||
assert(wallet.getBalance().total() > 0uL) | ||
|
||
val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.TESTNET) | ||
val psbt: PartiallySignedTransaction = TxBuilder() | ||
.addRecipient(recipient.scriptPubkey(), 4200uL) | ||
.feeRate(2.0f) | ||
.finish(wallet) | ||
|
||
println(psbt.serialize()) | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveWalletTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.bitcoindevkit | ||
|
||
import org.junit.Test | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class LiveWalletTest { | ||
@Test | ||
fun testSyncedBalance() { | ||
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()}") | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/OfflineDescriptorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.bitcoindevkit | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertTrue | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class OfflineDescriptorTest { | ||
@Test | ||
fun testDescriptorBip86() { | ||
val mnemonic: Mnemonic = Mnemonic(WordCount.WORDS12) | ||
val descriptorSecretKey: DescriptorSecretKey = DescriptorSecretKey(Network.TESTNET, mnemonic, null) | ||
val descriptor: Descriptor = Descriptor.newBip86(descriptorSecretKey, KeychainKind.EXTERNAL, Network.TESTNET) | ||
|
||
assertTrue(descriptor.asString().startsWith("tr"), "Bip86 Descriptor does not start with 'tr'") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/JvmLibTest.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import bdkpython as bdk | ||
import unittest | ||
|
||
class TestLiveTxBuilder(unittest.TestCase): | ||
|
||
def test_tx_builder(self): | ||
descriptor: bdk.Descriptor = bdk.Descriptor( | ||
"wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", | ||
bdk.Network.TESTNET | ||
) | ||
wallet: bdk.Wallet = bdk.Wallet.new_no_persist( | ||
descriptor, | ||
None, | ||
bdk.Network.TESTNET | ||
) | ||
esploraClient: bdk.EsploraClient = bdk.EsploraClient(url = "https://mempool.space/testnet/api") | ||
update = esploraClient.scan( | ||
wallet = wallet, | ||
stop_gap = 10, | ||
parallel_requests = 1 | ||
) | ||
wallet.apply_update(update) | ||
|
||
self.assertGreater(wallet.get_balance().total(), 0) | ||
|
||
recipient = bdk.Address( | ||
address = "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", | ||
network = bdk.Network.TESTNET | ||
) | ||
|
||
psbt = bdk.TxBuilder().add_recipient(script=recipient.script_pubkey(), amount=4200).fee_rate(2.0).finish(wallet) | ||
# print(psbt.serialize()) | ||
|
||
self.assertTrue(psbt.serialize().startswith("cHNi"), "The PSBT should start with cHNi") | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import bdkpython as bdk | ||
import unittest | ||
|
||
class TestLiveWallet(unittest.TestCase): | ||
|
||
def test_synced_balance(self): | ||
descriptor: bdk.Descriptor = bdk.Descriptor( | ||
"wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", | ||
bdk.Network.TESTNET | ||
) | ||
wallet: bdk.Wallet = bdk.Wallet.new_no_persist( | ||
descriptor, | ||
None, | ||
bdk.Network.TESTNET | ||
) | ||
esploraClient: bdk.EsploraClient = bdk.EsploraClient(url = "https://mempool.space/testnet/api") | ||
update = esploraClient.scan( | ||
wallet = wallet, | ||
stop_gap = 10, | ||
parallel_requests = 1 | ||
) | ||
wallet.apply_update(update) | ||
|
||
self.assertGreater(wallet.get_balance().total(), 0) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import bdkpython as bdk | ||
import unittest | ||
|
||
class TestSimpleWallet(unittest.TestCase): | ||
|
||
def test_descriptor_bip86(self): | ||
mnemonic: bdk.Mnemonic = bdk.Mnemonic(bdk.WordCount.WORDS12) | ||
descriptor_secret_key: bdk.DescriptorSecretKey = bdk.DescriptorSecretKey(bdk.Network.TESTNET, mnemonic, None) | ||
descriptor: bdk.Descriptor = bdk.Descriptor.new_bip86(descriptor_secret_key, bdk.KeychainKind.EXTERNAL, bdk.Network.TESTNET) | ||
|
||
self.assertTrue(descriptor.as_string().startswith("tr"), "Bip86 Descriptor does not start with 'tr'") | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.