Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Testnet4 addition #92

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl Network {

pub fn genesis_hash(network: Network) -> BlockHash {
#[cfg(not(feature = "liquid"))]
return bitcoin_genesis_hash(network.into());
return bitcoin_genesis_hash(network);
#[cfg(feature = "liquid")]
return liquid_genesis_hash(network);
}
Expand All @@ -139,20 +139,29 @@ pub fn bitcoin_genesis_hash(network: Network) -> bitcoin::BlockHash {
genesis_block(BNetwork::Bitcoin).block_hash();
static ref TESTNET_GENESIS: bitcoin::BlockHash =
genesis_block(BNetwork::Testnet).block_hash();
static ref TESTNET4_GENESIS: bitcoin::BlockHash =
BlockHash::from_str("00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043").unwrap();
static ref TESTNET4_GENESIS: bitcoin::BlockHash = bitcoin::BlockHash::from_str(
"00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043"
)
.unwrap();
static ref REGTEST_GENESIS: bitcoin::BlockHash =
genesis_block(BNetwork::Regtest).block_hash();
static ref SIGNET_GENESIS: bitcoin::BlockHash =
genesis_block(BNetwork::Signet).block_hash();
}
#[cfg(not(feature = "liquid"))]
match network {
Network::Bitcoin => *BITCOIN_GENESIS,
Network::Testnet => *TESTNET_GENESIS,
Network::Testnet4 => *TESTNET4_GENESIS,
Network::Regtest => *REGTEST_GENESIS,
Network::Signet => *SIGNET_GENESIS,
}
#[cfg(feature = "liquid")]
match network {
Network::Liquid => *BITCOIN_GENESIS,
Network::LiquidTestnet => *TESTNET_GENESIS,
Network::LiquidRegtest => *REGTEST_GENESIS,
}
}

#[cfg(feature = "liquid")]
Expand Down
1 change: 1 addition & 0 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ pub struct Daemon {
}

impl Daemon {
#[allow(clippy::too_many_arguments)]
pub fn new(
daemon_dir: PathBuf,
blocks_dir: PathBuf,
Expand Down
8 changes: 7 additions & 1 deletion src/elements/peg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ pub fn get_pegout_data(
let pegged_asset_id = network.pegged_asset()?;
txout.pegout_data().filter(|pegout| {
pegout.asset == Asset::Explicit(*pegged_asset_id)
&& pegout.genesis_hash == bitcoin_genesis_hash(parent_network)
&& pegout.genesis_hash
== bitcoin_genesis_hash(match parent_network {
BNetwork::Bitcoin => Network::Liquid,
BNetwork::Testnet => Network::LiquidTestnet,
BNetwork::Signet => return false,
BNetwork::Regtest => Network::LiquidRegtest,
})
})
}

Expand Down
5 changes: 4 additions & 1 deletion src/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,10 @@ fn address_to_scripthash(addr: &str, network: Network) -> Result<FullHash, HttpE
// `addr_network` will be detected as Testnet for all of them.
addr_network == network
|| (addr_network == Network::Testnet
&& matches!(network, Network::Regtest | Network::Signet | Network::Testnet4))
&& matches!(
network,
Network::Regtest | Network::Signet | Network::Testnet4
))
};

#[cfg(feature = "liquid")]
Expand Down
Loading