Skip to content

Commit

Permalink
Make SIGHASH_FORKID configurable with coins file #905 (#912)
Browse files Browse the repository at this point in the history
* Make SIGHASH_FORKID configurable with coins file

* added hardcoded BCH fork_id for non updated config

* fix code format
  • Loading branch information
shamardy authored Apr 21, 2021
1 parent 2adfc36 commit 2b3db4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions mm2src/coins/utxo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,11 +916,13 @@ impl<'a> UtxoConfBuilder<'a> {
}

fn fork_id(&self) -> u32 {
if self.ticker == "BCH" {
0x40
} else {
0
}
let default_fork_id = match self.ticker {
"BCH" => "0x40",
_ => "0x0",
};
let hex_string = self.conf["fork_id"].as_str().unwrap_or(default_fork_id);
let fork_id = u32::from_str_radix(hex_string.trim_start_matches("0x"), 16).unwrap();
fork_id
}

fn required_confirmations(&self) -> u64 {
Expand Down
2 changes: 1 addition & 1 deletion mm2src/mm2_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3417,7 +3417,7 @@ fn spin_n_nodes(seednodes: &[&str], coins: &Json, n: usize) -> Vec<(MarketMakerI
#[cfg(not(target_arch = "wasm32"))]
fn test_withdraw_cashaddresses() {
let coins = json!([
{"coin":"BCH","pubtype":0,"p2shtype":5,"mm2":1,"protocol":{"type":"UTXO"},
{"coin":"BCH","pubtype":0,"p2shtype":5,"mm2":1,"fork_id": "0x40","protocol":{"type":"UTXO"},
"address_format":{"format":"cashaddress","network":"bchtest"}},
]);

Expand Down

0 comments on commit 2b3db4f

Please sign in to comment.