From 33f6cae22884bd3c46f2fa848e3ad033b41cd772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ceyhun=20=C5=9Een?= Date: Fri, 20 Dec 2024 17:15:29 +0300 Subject: [PATCH] build-transaction: Fix n-of-n 1 week address bug. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Atacan İyidoğan --- core/src/builder/transaction.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/builder/transaction.rs b/core/src/builder/transaction.rs index ac7f771c..cc0c9e3d 100644 --- a/core/src/builder/transaction.rs +++ b/core/src/builder/transaction.rs @@ -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. @@ -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), ]);