Skip to content

Commit 945408b

Browse files
feat: add support for testnet 4
1 parent a0842c6 commit 945408b

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

app/src/main/java/org/bitcoindevkit/devkitwallet/domain/BlockchainClientsConfig.kt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,11 @@ class BlockchainClientsConfig {
4040
fun createDefaultConfig(network: Network): BlockchainClientsConfig {
4141
val config = BlockchainClientsConfig()
4242
when (network) {
43-
Network.REGTEST -> {
44-
config.addClient(EsploraClient("http://10.0.2.2:3002"), true)
45-
}
46-
Network.TESTNET -> {
47-
config.addClient(EsploraClient("https://blockstream.info/testnet/api/"), true)
48-
}
49-
Network.TESTNET4 -> throw IllegalArgumentException("This app does not support testnet 4 yet")
50-
Network.SIGNET -> {
51-
config.addClient(EsploraClient("http://signet.bitcoindevkit.net"), true)
52-
}
53-
Network.BITCOIN -> throw IllegalArgumentException("This app does not support mainnet")
43+
Network.REGTEST -> config.addClient(EsploraClient("http://10.0.2.2:3002"), true)
44+
Network.SIGNET -> config.addClient(EsploraClient("http://signet.bitcoindevkit.net"), true)
45+
Network.TESTNET -> config.addClient(EsploraClient("https://blockstream.info/testnet/api/"), true)
46+
Network.TESTNET4 -> config.addClient(EsploraClient("https://mempool.space/testnet4/api/"), true)
47+
Network.BITCOIN -> throw IllegalArgumentException("This app does not support mainnet")
5448
}
5549
return config
5650
}

app/src/main/java/org/bitcoindevkit/devkitwallet/domain/Constants.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
/*
2+
* Copyright 2021-2025 thunderbiscuit and contributors.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the ./LICENSE file.
4+
*/
5+
16
package org.bitcoindevkit.devkitwallet.domain
27

38
import org.bitcoindevkit.Network
49

510
val supportedNetworks: List<Network> = listOf(
611
Network.SIGNET,
712
Network.TESTNET,
13+
Network.TESTNET4,
814
Network.REGTEST,
915
)
1016

app/src/main/java/org/bitcoindevkit/devkitwallet/domain/utils/ProtobufExtensions.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ import org.bitcoindevkit.devkitwallet.data.ActiveWalletNetwork
1111
fun Network.intoProto(): ActiveWalletNetwork {
1212
return when (this) {
1313
Network.REGTEST -> ActiveWalletNetwork.REGTEST
14-
Network.TESTNET -> ActiveWalletNetwork.TESTNET
15-
Network.TESTNET4 -> throw IllegalArgumentException("Bitcoin testnet 4 network is not supported")
14+
Network.TESTNET -> ActiveWalletNetwork.TESTNET3
15+
Network.TESTNET4 -> ActiveWalletNetwork.TESTNET4
1616
Network.SIGNET -> ActiveWalletNetwork.SIGNET
1717
Network.BITCOIN -> throw IllegalArgumentException("Bitcoin mainnet network is not supported")
1818
}
1919
}
2020

2121
fun ActiveWalletNetwork.intoDomain(): Network {
2222
return when (this) {
23-
ActiveWalletNetwork.TESTNET -> Network.TESTNET
24-
ActiveWalletNetwork.SIGNET -> Network.SIGNET
25-
ActiveWalletNetwork.REGTEST -> Network.REGTEST
23+
ActiveWalletNetwork.REGTEST -> Network.REGTEST
24+
ActiveWalletNetwork.SIGNET -> Network.SIGNET
25+
ActiveWalletNetwork.TESTNET3 -> Network.TESTNET
26+
ActiveWalletNetwork.TESTNET4 -> Network.TESTNET4
2627
ActiveWalletNetwork.UNRECOGNIZED -> throw IllegalArgumentException("Unrecognized network")
2728
}
2829
}

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/ui/components/WalletOptionsCard.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fun WalletOptionsCard(
6060
isSelected = selectedNetwork.value == it,
6161
onSelect = { selectedNetwork.value = it }
6262
)
63-
if (index == 2) Spacer(modifier = Modifier.padding(bottom = 8.dp))
63+
if (index == 3) Spacer(modifier = Modifier.padding(bottom = 8.dp))
6464
}
6565

6666
Text(

app/src/main/proto/wallets.proto

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ message SingleWallet {
2020
}
2121

2222
enum ActiveWalletNetwork {
23-
TESTNET = 0;
23+
REGTEST = 0;
2424
SIGNET = 1;
25-
REGTEST = 2;
25+
TESTNET3 = 2;
26+
TESTNET4 = 3;
2627
}
2728

2829
enum ActiveWalletScriptType {

0 commit comments

Comments
 (0)