Skip to content

Commit

Permalink
Set correct threshold and network in recover-deposit
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Feb 14, 2024
1 parent 5f7a707 commit 9091c12
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/bin/nomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2007,6 +2007,12 @@ impl RecoverDepositCmd {
)));
}

let threshold = self
.config
.client()
.query(|app| Ok(app.bitcoin.checkpoints.config.sigset_threshold))
.await?;

// TODO: support passing in script csv by path
let sigsets: Vec<(u32, SignatorySet)> = std::fs::read_to_string(&self.reserve_script_path)?
.lines()
Expand Down Expand Up @@ -2055,9 +2061,9 @@ impl RecoverDepositCmd {
}
}

let script = sigset.output_script(&dest_bytes, (2, 3)).unwrap();
let script = sigset.output_script(&dest_bytes, threshold).unwrap();
let addr =
bitcoin::Address::from_script(&script, bitcoin::Network::Bitcoin).unwrap();
bitcoin::Address::from_script(&script, nomic::bitcoin::NETWORK).unwrap();
if addr.to_string().to_lowercase()
== self.deposit_addr.to_string().to_lowercase()
{
Expand Down Expand Up @@ -2089,8 +2095,8 @@ impl RecoverDepositCmd {
let dest_bytes = dest.commitment_bytes().unwrap();

for (sigset_index, sigset) in sigsets.iter() {
let script = sigset.output_script(&dest_bytes, (2, 3)).unwrap();
let addr = bitcoin::Address::from_script(&script, bitcoin::Network::Bitcoin).unwrap();
let script = sigset.output_script(&dest_bytes, threshold).unwrap();
let addr = bitcoin::Address::from_script(&script, nomic::bitcoin::NETWORK).unwrap();
if addr.to_string().to_lowercase() == self.deposit_addr.to_string().to_lowercase() {
println!("Found at sigset index {}", sigset_index,);
return self.relay_deposit(dest, *sigset_index).await;
Expand Down

0 comments on commit 9091c12

Please sign in to comment.