Skip to content

Commit

Permalink
complete signet support
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedberg committed Dec 18, 2024
1 parent ffbed00 commit 091f785
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, AppError> {
BitcoinNetwork::Regtest,
BitcoinNetwork::Signet,
];

if !supported_networks.contains(&network) {
return Err(AppError::UnsupportedBitcoinNetwork);
}
Expand Down
11 changes: 6 additions & 5 deletions src/ldk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ use crate::routes::{HTLCStatus, SwapStatus, UnlockRequest, DUST_LIMIT_MSAT};
use crate::swap::SwapData;
use crate::utils::{
check_port_is_available, connect_peer_if_necessary, do_connect_peer, get_current_timestamp,
hex_str, AppState, StaticState, UnlockedAppState, ELECTRUM_URL_REGTEST, ELECTRUM_URL_TESTNET,
PROXY_ENDPOINT_REGTEST, PROXY_ENDPOINT_TESTNET,
hex_str, AppState, StaticState, UnlockedAppState, ELECTRUM_URL_REGTEST, ELECTRUM_URL_SIGNET,
ELECTRUM_URL_TESTNET, PROXY_ENDPOINT_LOCAL, PROXY_ENDPOINT_PUBLIC,
};

pub(crate) const FEE_RATE: f32 = 7.0;
Expand Down Expand Up @@ -1446,8 +1446,9 @@ pub(crate) async fn start_ldk(
} else {
tracing::info!("Using the default indexer");
match bitcoin_network {
BitcoinNetwork::Testnet => ELECTRUM_URL_TESTNET,
BitcoinNetwork::Regtest => ELECTRUM_URL_REGTEST,
BitcoinNetwork::Signet => ELECTRUM_URL_SIGNET,
BitcoinNetwork::Testnet => ELECTRUM_URL_TESTNET,
_ => unimplemented!("unsupported network"),
}
};
Expand All @@ -1458,8 +1459,8 @@ pub(crate) async fn start_ldk(
} else {
tracing::info!("Using the default proxy");
match bitcoin_network {
BitcoinNetwork::Testnet => PROXY_ENDPOINT_TESTNET,
BitcoinNetwork::Regtest => PROXY_ENDPOINT_REGTEST,
BitcoinNetwork::Signet | BitcoinNetwork::Testnet => PROXY_ENDPOINT_PUBLIC,
BitcoinNetwork::Regtest => PROXY_ENDPOINT_LOCAL,
_ => unimplemented!("unsupported network"),
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::routes::{
SendBtcResponse, SendPaymentRequest, SendPaymentResponse, SwapStatus, TakerRequest,
Transaction, Transfer, UnlockRequest, Unspent,
};
use crate::utils::{hex_str_to_vec, ELECTRUM_URL_REGTEST, PROXY_ENDPOINT_REGTEST};
use crate::utils::{hex_str_to_vec, ELECTRUM_URL_REGTEST, PROXY_ENDPOINT_LOCAL};

use super::*;

Expand Down Expand Up @@ -1188,7 +1188,7 @@ async fn send_asset(node_address: SocketAddr, asset_id: &str, amount: u64, recip
donation: true,
fee_rate: FEE_RATE,
min_confirmations: 1,
transport_endpoints: vec![PROXY_ENDPOINT_REGTEST.to_string()],
transport_endpoints: vec![PROXY_ENDPOINT_LOCAL.to_string()],
skip_sync: false,
};
let res = reqwest::Client::new()
Expand Down Expand Up @@ -1345,7 +1345,7 @@ async fn unlock_res(node_address: SocketAddr, password: &str) -> Response {
bitcoind_rpc_host: s!("localhost"),
bitcoind_rpc_port: 18443,
indexer_url: Some(ELECTRUM_URL_REGTEST.to_string()),
proxy_endpoint: Some(PROXY_ENDPOINT_REGTEST.to_string()),
proxy_endpoint: Some(PROXY_ENDPOINT_LOCAL.to_string()),
announce_addresses: vec![],
announce_alias: Some(s!("RLN_alias")),
};
Expand Down
2 changes: 1 addition & 1 deletion src/test/send_receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async fn send_receive() {
assert_eq!(decoded.amount, None);
assert!(matches!(decoded.network, BitcoinNetwork::Regtest));
assert!(decoded.expiration_timestamp.is_some());
assert_eq!(decoded.transport_endpoints, vec![PROXY_ENDPOINT_REGTEST]);
assert_eq!(decoded.transport_endpoints, vec![PROXY_ENDPOINT_LOCAL]);

let recipient_id = rgb_invoice(node2_addr, None).await.recipient_id;
send_asset(node1_addr, &asset_id, 200, recipient_id).await;
Expand Down
5 changes: 3 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ use crate::{
pub(crate) const LDK_DIR: &str = ".ldk";
pub(crate) const LOGS_DIR: &str = "logs";
pub(crate) const ELECTRUM_URL_REGTEST: &str = "127.0.0.1:50001";
pub(crate) const ELECTRUM_URL_SIGNET: &str = "ssl://electrum.iriswallet.com:50033";
pub(crate) const ELECTRUM_URL_TESTNET: &str = "ssl://electrum.iriswallet.com:50013";
pub(crate) const PROXY_ENDPOINT_REGTEST: &str = "rpc://127.0.0.1:3000/json-rpc";
pub(crate) const PROXY_ENDPOINT_TESTNET: &str = "rpcs://proxy.iriswallet.com/0.2/json-rpc";
pub(crate) const PROXY_ENDPOINT_LOCAL: &str = "rpc://127.0.0.1:3000/json-rpc";
pub(crate) const PROXY_ENDPOINT_PUBLIC: &str = "rpcs://proxy.iriswallet.com/0.2/json-rpc";
const PASSWORD_MIN_LENGTH: u8 = 8;

pub(crate) struct AppState {
Expand Down

0 comments on commit 091f785

Please sign in to comment.