Skip to content

Commit

Permalink
op challenge nack bugfix (#387)
Browse files Browse the repository at this point in the history
* fix vout of operator challenge nack txin and some typos

* fix some typos

* remove unnecessary parameter
  • Loading branch information
atacann authored Jan 3, 2025
1 parent b339085 commit b4c5b04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
19 changes: 9 additions & 10 deletions core/src/builder/sighash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ pub fn create_nofn_sighash_stream(
futures::future::try_join_all(watchtower_challenge_wotss).await?;

let mut input_txid = *collateral_funding_txid;
let mut input_amunt = collateral_funding_amount;
let mut input_amount = collateral_funding_amount;

for time_tx_idx in 0..config.num_time_txs {
let time_txid = builder::transaction::create_time_tx(
*operator_xonly_pk,
input_txid,
input_amunt,
input_amount,
timeout_block_count,
max_withdrawal_time_block_count,
network,
Expand Down Expand Up @@ -128,8 +128,7 @@ pub fn create_nofn_sighash_stream(
watchtower_challenge_txhandler.tx.compute_txid(),
time_txid,
kickoff_txid,
input_amunt,
i,
input_amount,
&[0u8; 20],
nofn_xonly_pk,
*operator_xonly_pk,
Expand Down Expand Up @@ -173,12 +172,12 @@ pub fn create_nofn_sighash_stream(
let time2_tx = builder::transaction::create_time2_tx(
*operator_xonly_pk,
time_txid,
input_amunt,
input_amount,
network,
);

input_txid = time2_tx.compute_txid();
input_amunt = time2_tx.output[0].value;
input_amount = time2_tx.output[0].value;
}
}
}
Expand All @@ -194,14 +193,14 @@ pub fn create_timout_tx_sighash_stream(
network: bitcoin::Network,
) -> impl Stream<Item = Result<TapSighash, BridgeError>> {
let mut input_txid = collateral_funding_txid;
let mut input_amunt = collateral_funding_amount;
let mut input_amount = collateral_funding_amount;

try_stream! {
for _ in 0..num_time_txs {
let time_tx = builder::transaction::create_time_tx(
operator_xonly_pk,
input_txid,
input_amunt,
input_amount,
timeout_block_count,
max_withdrawal_time_block_count,
network,
Expand All @@ -219,12 +218,12 @@ pub fn create_timout_tx_sighash_stream(
let time2_tx = builder::transaction::create_time2_tx(
operator_xonly_pk,
time_tx.compute_txid(),
input_amunt,
input_amount,
network,
);

input_txid = time2_tx.compute_txid();
input_amunt = time2_tx.output[0].value;
input_amount = time2_tx.output[0].value;
}
}
}
13 changes: 6 additions & 7 deletions core/src/builder/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn create_time_tx(
max_withdrawal_time_block_count,
);

let timout_block_count_locked_script =
let timeout_block_count_locked_script =
builder::script::generate_relative_timelock_script(operator_xonly_pk, timeout_block_count);

let tx_outs = vec![
Expand All @@ -100,7 +100,7 @@ pub fn create_time_tx(
TxOut {
value: KICKOFF_INPUT_AMOUNT,
script_pubkey: create_taproot_address(
&[timout_block_count_locked_script],
&[timeout_block_count_locked_script],
Some(operator_xonly_pk),
network,
)
Expand Down Expand Up @@ -169,11 +169,11 @@ pub fn create_timeout_tx_handler(

let tx = create_btc_tx(tx_ins, tx_outs);

let timout_block_count_locked_script =
let timeout_block_count_locked_script =
builder::script::generate_relative_timelock_script(operator_xonly_pk, timeout_block_count);

let (timeout_input_addr, ttimeout_input_taproot_spend_info) = create_taproot_address(
&[timout_block_count_locked_script.clone()],
&[timeout_block_count_locked_script.clone()],
Some(operator_xonly_pk),
network,
);
Expand All @@ -182,7 +182,7 @@ pub fn create_timeout_tx_handler(
value: KICKOFF_INPUT_AMOUNT,
script_pubkey: timeout_input_addr.script_pubkey(),
}];
let scripts = vec![vec![timout_block_count_locked_script]];
let scripts = vec![vec![timeout_block_count_locked_script]];
let taproot_spend_infos = vec![ttimeout_input_taproot_spend_info];
TxHandler {
tx,
Expand Down Expand Up @@ -483,7 +483,6 @@ pub fn create_operator_challenge_nack_txhandler(
time_txid: Txid,
kickoff_txid: Txid,
time_tx_amount: Amount,
watchtower_idx: usize,
operator_unlock_hash: &[u8; 20],
nofn_xonly_pk: XOnlyPublicKey,
operator_xonly_pk: XOnlyPublicKey,
Expand All @@ -492,7 +491,7 @@ pub fn create_operator_challenge_nack_txhandler(
let tx_ins = create_tx_ins(vec![
OutPoint {
txid: watchtower_challenge_txid,
vout: watchtower_idx as u32,
vout: 0,
},
OutPoint {
txid: kickoff_txid,
Expand Down

0 comments on commit b4c5b04

Please sign in to comment.