Skip to content

Commit

Permalink
build-transaction: Fix n-of-n 1 week address bug.
Browse files Browse the repository at this point in the history
Co-authored-by: Atacan İyidoğan <[email protected]>
  • Loading branch information
ceyhunsen and Atacan İyidoğan committed Dec 20, 2024
1 parent 091369f commit 33f6cae
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions core/src/builder/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bitcoin::script::PushBytesBuf;
use bitcoin::{
absolute, taproot::TaprootSpendInfo, Address, Amount, OutPoint, ScriptBuf, TxIn, TxOut, Witness,
};
use bitcoin::{Transaction, Txid};
use bitcoin::{Network, Transaction, Txid};
use secp256k1::XOnlyPublicKey;

/// Verbose information about a transaction.
Expand Down Expand Up @@ -314,21 +314,22 @@ pub fn create_kickoff_tx(
time_tx_outpoint: OutPoint,
nofn_xonly_pk: XOnlyPublicKey,
user_evm_address: EVMAddress,
network: Network,
) -> Transaction {
let nofn_script = builder::script::create_deposit_script(
nofn_xonly_pk,
user_evm_address,
KICKOFF_UTXO_AMOUNT_SATS,
);
let nofn_or_1_week_script = builder::script::generate_relative_timelock_script(
nofn_xonly_pk,
1008, // 1 week in blocks
);

let nofn_1week = builder::script::generate_relative_timelock_script(nofn_xonly_pk, 7 * 24 * 6);
let (nofn_or_nofn_1week, _) =
builder::address::create_taproot_address(&[nofn_1week], Some(nofn_xonly_pk), network);

let tx_ins = create_tx_ins(vec![time_tx_outpoint]);
let tx_outs = create_tx_outs(vec![
(KICKOFF_UTXO_AMOUNT_SATS, nofn_script.clone()),
(KICKOFF_UTXO_AMOUNT_SATS, nofn_or_1_week_script),
(KICKOFF_UTXO_AMOUNT_SATS, nofn_or_nofn_1week.script_pubkey()),
(KICKOFF_UTXO_AMOUNT_SATS, nofn_script),
]);

Expand Down

0 comments on commit 33f6cae

Please sign in to comment.