Skip to content

Commit f379330

Browse files
committed
add support for testnet4
1 parent bd13e15 commit f379330

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,13 @@ When unlocking regtest nodes use the following local services:
116116

117117
### Testnet
118118

119-
When running the node on the testnet network the docker services are not needed
119+
#### Testnet3
120+
121+
When running the node on the testnet3 network the docker services are not needed
120122
because the node will use some public services.
121123

122-
Here's an example of how to start three testnet nodes, each one using the
123-
external testnet services:
124+
Here's an example of how to start three testnet3 nodes, each one using the
125+
external testnet3 services:
124126

125127
```sh
126128
# 1st shell
@@ -139,14 +141,21 @@ rgb-lightning-node dataldk2/ --daemon-listening-port 3003 \
139141
--disable-authentication
140142
```
141143

142-
When unlocking testnet nodes you can use the following services:
144+
When unlocking testnet3 nodes you can use the following services:
143145
- bitcoind_rpc_username: user
144146
- bitcoind_rpc_username: password
145147
- bitcoind_rpc_host: electrum.iriswallet.com
146148
- bitcoind_rpc_port: 18332
147149
- indexer_url: ssl://electrum.iriswallet.com:50013
148150
- proxy_endpoint: rpcs://proxy.iriswallet.com/0.2/json-rpc
149151

152+
#### Testnet4
153+
154+
To run testnet4 use the same options as testnet3 except for:
155+
- CLI arg: `--network testnet4`
156+
- bitcoind_rpc_port: 18443
157+
- indexer_url: ssl://electrum.iriswallet.com:50053
158+
150159
## Use
151160

152161
Once daemons are running, they can be operated via REST JSON APIs.

openapi.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,7 @@ components:
12081208
enum:
12091209
- Mainnet
12101210
- Testnet
1211+
- Testnet4
12111212
- Signet
12121213
- Regtest
12131214
BlockTime:

src/ldk.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ use crate::swap::SwapData;
9494
use crate::utils::{
9595
check_port_is_available, connect_peer_if_necessary, do_connect_peer, get_current_timestamp,
9696
hex_str, AppState, StaticState, UnlockedAppState, ELECTRUM_URL_MAINNET, ELECTRUM_URL_REGTEST,
97-
ELECTRUM_URL_SIGNET, ELECTRUM_URL_TESTNET, PROXY_ENDPOINT_LOCAL, PROXY_ENDPOINT_PUBLIC,
97+
ELECTRUM_URL_SIGNET, ELECTRUM_URL_TESTNET, ELECTRUM_URL_TESTNET4, PROXY_ENDPOINT_LOCAL,
98+
PROXY_ENDPOINT_PUBLIC,
9899
};
99100

100101
pub(crate) const FEE_RATE: u64 = 7;
@@ -518,10 +519,11 @@ async fn handle_ldk_events(
518519
output_script.as_bytes(),
519520
match static_state.network {
520521
BitcoinNetwork::Mainnet => bitcoin_bech32::constants::Network::Bitcoin,
521-
BitcoinNetwork::Testnet => bitcoin_bech32::constants::Network::Testnet,
522+
BitcoinNetwork::Testnet | BitcoinNetwork::Testnet4 => {
523+
bitcoin_bech32::constants::Network::Testnet
524+
}
522525
BitcoinNetwork::Regtest => bitcoin_bech32::constants::Network::Regtest,
523526
BitcoinNetwork::Signet => bitcoin_bech32::constants::Network::Signet,
524-
_ => todo!(),
525527
},
526528
)
527529
.expect("Lightning funding tx should always be to a SegWit output");
@@ -1472,9 +1474,9 @@ pub(crate) async fn start_ldk(
14721474
!= match bitcoin_network {
14731475
BitcoinNetwork::Mainnet => "main",
14741476
BitcoinNetwork::Testnet => "test",
1477+
BitcoinNetwork::Testnet4 => "testnet4",
14751478
BitcoinNetwork::Regtest => "regtest",
14761479
BitcoinNetwork::Signet => "signet",
1477-
_ => todo!(),
14781480
}
14791481
{
14801482
return Err(APIError::NetworkMismatch(bitcoind_chain, bitcoin_network));
@@ -1494,8 +1496,8 @@ pub(crate) async fn start_ldk(
14941496
BitcoinNetwork::Regtest => ELECTRUM_URL_REGTEST,
14951497
BitcoinNetwork::Signet => ELECTRUM_URL_SIGNET,
14961498
BitcoinNetwork::Testnet => ELECTRUM_URL_TESTNET,
1499+
BitcoinNetwork::Testnet4 => ELECTRUM_URL_TESTNET4,
14971500
BitcoinNetwork::Mainnet => ELECTRUM_URL_MAINNET,
1498-
_ => todo!(),
14991501
}
15001502
};
15011503
let proxy_endpoint = if let Some(proxy_endpoint) = &unlock_request.proxy_endpoint {
@@ -1505,11 +1507,11 @@ pub(crate) async fn start_ldk(
15051507
} else {
15061508
tracing::info!("Using the default proxy");
15071509
match bitcoin_network {
1508-
BitcoinNetwork::Signet | BitcoinNetwork::Testnet | BitcoinNetwork::Mainnet => {
1509-
PROXY_ENDPOINT_PUBLIC
1510-
}
1510+
BitcoinNetwork::Signet
1511+
| BitcoinNetwork::Testnet
1512+
| BitcoinNetwork::Testnet4
1513+
| BitcoinNetwork::Mainnet => PROXY_ENDPOINT_PUBLIC,
15111514
BitcoinNetwork::Regtest => PROXY_ENDPOINT_LOCAL,
1512-
_ => todo!(),
15131515
}
15141516
};
15151517
let storage_dir_path = app_state.static_state.storage_dir_path.clone();

src/routes.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ pub(crate) struct BackupRequest {
324324
pub(crate) enum BitcoinNetwork {
325325
Mainnet,
326326
Testnet,
327+
Testnet4,
327328
Signet,
328329
Regtest,
329330
}
@@ -333,6 +334,7 @@ impl From<Network> for BitcoinNetwork {
333334
match x {
334335
Network::Bitcoin => Self::Mainnet,
335336
Network::Testnet => Self::Testnet,
337+
Network::Testnet4 => Self::Testnet4,
336338
Network::Regtest => Self::Regtest,
337339
Network::Signet => Self::Signet,
338340
_ => unimplemented!("unsupported network"),
@@ -345,9 +347,9 @@ impl From<RgbLibNetwork> for BitcoinNetwork {
345347
match x {
346348
RgbLibNetwork::Mainnet => Self::Mainnet,
347349
RgbLibNetwork::Testnet => Self::Testnet,
350+
RgbLibNetwork::Testnet4 => Self::Testnet4,
348351
RgbLibNetwork::Regtest => Self::Regtest,
349352
RgbLibNetwork::Signet => Self::Signet,
350-
_ => todo!(),
351353
}
352354
}
353355
}
@@ -2523,10 +2525,9 @@ pub(crate) async fn ln_invoice(
25232525

25242526
let currency = match state.static_state.network {
25252527
RgbLibNetwork::Mainnet => Currency::Bitcoin,
2526-
RgbLibNetwork::Testnet => Currency::BitcoinTestnet,
2528+
RgbLibNetwork::Testnet | RgbLibNetwork::Testnet4 => Currency::BitcoinTestnet,
25272529
RgbLibNetwork::Regtest => Currency::Regtest,
25282530
RgbLibNetwork::Signet => Currency::Signet,
2529-
_ => todo!(),
25302531
};
25312532
let invoice = match create_invoice_from_channelmanager(
25322533
&unlocked_state.channel_manager,

src/utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub(crate) const LOGS_DIR: &str = "logs";
4949
pub(crate) const ELECTRUM_URL_REGTEST: &str = "127.0.0.1:50001";
5050
pub(crate) const ELECTRUM_URL_SIGNET: &str = "ssl://electrum.iriswallet.com:50033";
5151
pub(crate) const ELECTRUM_URL_TESTNET: &str = "ssl://electrum.iriswallet.com:50013";
52+
pub(crate) const ELECTRUM_URL_TESTNET4: &str = "ssl://electrum.iriswallet.com:50053";
5253
pub(crate) const ELECTRUM_URL_MAINNET: &str = "ssl://electrum.iriswallet.com:50003";
5354
pub(crate) const PROXY_ENDPOINT_LOCAL: &str = "rpc://127.0.0.1:3000/json-rpc";
5455
pub(crate) const PROXY_ENDPOINT_PUBLIC: &str = "rpcs://proxy.iriswallet.com/0.2/json-rpc";

0 commit comments

Comments
 (0)