0 => IntroductionNode::DirectedShortChannelId(Direction::NodeOne, Readable::read(r)?),
1 => IntroductionNode::DirectedShortChannelId(Direction::NodeTwo, Readable::read(r)?),
2|3 => {
- use io::Read;
let mut bytes = [0; 33];
bytes[0] = first_byte;
r.read_exact(&mut bytes[1..])?;
} = &event.event {
if event.transaction.as_ref().map(|tx| tx.input.iter().any(|inp| {
if let Some(htlc_spend_txid) = htlc_spend_txid_opt {
- tx.txid() == *htlc_spend_txid || inp.previous_output.txid == *htlc_spend_txid
+ tx.compute_txid() == *htlc_spend_txid || inp.previous_output.txid == *htlc_spend_txid
} else {
Some(inp.previous_output.txid) == confirmed_txid &&
inp.previous_output.vout == htlc_commitment_tx_output_idx
macro_rules! fail_unbroadcast_htlcs {
($self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr, $commitment_tx_confirmed: expr,
$commitment_tx_conf_height: expr, $commitment_tx_conf_hash: expr, $confirmed_htlcs_list: expr, $logger: expr) => { {
- debug_assert_eq!($commitment_tx_confirmed.txid(), $commitment_txid_confirmed);
+ debug_assert_eq!($commitment_tx_confirmed.compute_txid(), $commitment_txid_confirmed);
macro_rules! check_htlc_fails {
($txid: expr, $commitment_tx: expr, $per_commitment_outpoints: expr) => {
// introduced with v0.0.116. counterparty_node_id is guaranteed to be `Some`
// since v0.0.110.
let counterparty_node_id = self.counterparty_node_id.unwrap();
- let commitment_txid = commitment_tx.txid();
+ let commitment_txid = commitment_tx.compute_txid();
debug_assert_eq!(self.current_holder_commitment_tx.txid, commitment_txid);
let pending_htlcs = self.current_holder_commitment_tx.non_dust_htlcs();
let commitment_tx_fee_satoshis = self.channel_value_satoshis -
let mut claimable_outpoints = Vec::new();
let mut to_counterparty_output_info = None;
- let commitment_txid = tx.txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
+ let commitment_txid = tx.compute_txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
let per_commitment_option = self.counterparty_claimable_outpoints.get(&commitment_txid);
macro_rules! ignore_error {
};
let per_commitment_point = PublicKey::from_secret_key(&self.onchain_tx_handler.secp_ctx, &per_commitment_key);
- let htlc_txid = tx.txid();
+ let htlc_txid = tx.compute_txid();
let mut claimable_outpoints = vec![];
let mut outputs_to_watch = None;
// Previously, we would only claim HTLCs from revoked HTLC transactions if they had 1 input
/// Should not be used if check_spend_revoked_transaction succeeds.
/// Returns None unless the transaction is definitely one of our commitment transactions.
fn check_spend_holder_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, block_hash: &BlockHash, logger: &L) -> Option<(Vec<PackageTemplate>, TransactionOutputs)> where L::Target: Logger {
- let commitment_txid = tx.txid();
+ let commitment_txid = tx.compute_txid();
let mut claim_requests = Vec::new();
let mut watch_outputs = Vec::new();
) -> Vec<Transaction> where L::Target: Logger {
log_debug!(logger, "Getting signed copy of latest holder commitment transaction!");
let commitment_tx = self.onchain_tx_handler.get_fully_signed_copy_holder_tx(&self.funding_redeemscript);
- let txid = commitment_tx.txid();
+ let txid = commitment_tx.compute_txid();
let mut holder_transactions = vec![commitment_tx];
// When anchor outputs are present, the HTLC transactions are only final once the commitment
// transaction confirms due to the CSV 1 encumberance.
let mut watch_outputs = Vec::new();
let mut claimable_outpoints = Vec::new();
'tx_iter: for tx in &txn_matched {
- let txid = tx.txid();
+ let txid = tx.compute_txid();
log_trace!(logger, "Transaction {} confirmed in block {}", txid , block_hash);
// If a transaction has already been confirmed, ensure we don't bother processing it duplicatively.
if Some(txid) == self.funding_spend_confirmed {
// make sure the registered scriptpubkey at the expected index match
// the actual transaction output one. We failed this case before #653.
for tx in &txn_matched {
- if let Some(outputs) = self.get_outputs_to_watch().get(&tx.txid()) {
+ if let Some(outputs) = self.get_outputs_to_watch().get(&tx.compute_txid()) {
for idx_and_script in outputs.iter() {
assert!((idx_and_script.0 as usize) < tx.output.len());
assert_eq!(tx.output[idx_and_script.0 as usize].script_pubkey, idx_and_script.1);
}
}
if matches {
- matched_txn.insert(tx.txid());
+ matched_txn.insert(tx.compute_txid());
}
matches
}).map(|(_, tx)| *tx).collect()
if ($holder_tx && revocation_sig_claim) ||
(outbound_htlc && !$source_avail && (accepted_preimage_claim || offered_preimage_claim)) {
log_error!(logger, "Input spending {} ({}:{}) in {} resolves {} HTLC with payment hash {} with {}!",
- $tx_info, input.previous_output.txid, input.previous_output.vout, tx.txid(),
+ $tx_info, input.previous_output.txid, input.previous_output.vout, tx.compute_txid(),
if outbound_htlc { "outbound" } else { "inbound" }, &$htlc.payment_hash,
if revocation_sig_claim { "revocation sig" } else { "preimage claim after we'd passed the HTLC resolution back. We can likely claim the HTLC output with a revocation claim" });
} else {
log_info!(logger, "Input spending {} ({}:{}) in {} resolves {} HTLC with payment hash {} with {}",
- $tx_info, input.previous_output.txid, input.previous_output.vout, tx.txid(),
+ $tx_info, input.previous_output.txid, input.previous_output.vout, tx.compute_txid(),
if outbound_htlc { "outbound" } else { "inbound" }, &$htlc.payment_hash,
if revocation_sig_claim { "revocation sig" } else if accepted_preimage_claim || offered_preimage_claim { "preimage" } else { "timeout" });
}
log_claim!($tx_info, $holder_tx, htlc_output, false);
let outbound_htlc = $holder_tx == htlc_output.offered;
self.onchain_events_awaiting_threshold_conf.push(OnchainEventEntry {
- txid: tx.txid(), height, block_hash: Some(*block_hash), transaction: Some(tx.clone()),
+ txid: tx.compute_txid(), height, block_hash: Some(*block_hash), transaction: Some(tx.clone()),
event: OnchainEvent::HTLCSpendConfirmation {
commitment_tx_output_idx: input.previous_output.vout,
preimage: if accepted_preimage_claim || offered_preimage_claim {
if !self.pending_monitor_events.iter().any(
|update| if let &MonitorEvent::HTLCEvent(ref upd) = update { upd.source == source } else { false }) {
self.onchain_events_awaiting_threshold_conf.push(OnchainEventEntry {
- txid: tx.txid(),
+ txid: tx.compute_txid(),
height,
block_hash: Some(*block_hash),
transaction: Some(tx.clone()),
upd.source == source
} else { false }) {
self.onchain_events_awaiting_threshold_conf.push(OnchainEventEntry {
- txid: tx.txid(),
+ txid: tx.compute_txid(),
transaction: Some(tx.clone()),
height,
block_hash: Some(*block_hash),
}
});
let entry = OnchainEventEntry {
- txid: tx.txid(),
+ txid: tx.compute_txid(),
transaction: Some(tx.clone()),
height,
block_hash: Some(*block_hash),
for (i, outp) in tx.output.iter().enumerate() {
if outp.script_pubkey == self.destination_script {
spendable_outputs.push(SpendableOutputDescriptor::StaticOutput {
- outpoint: OutPoint { txid: tx.txid(), index: i as u16 },
+ outpoint: OutPoint { txid: tx.compute_txid(), index: i as u16 },
output: outp.clone(),
channel_keys_id: Some(self.channel_keys_id),
});
if let Some(ref broadcasted_holder_revokable_script) = self.broadcasted_holder_revokable_script {
if broadcasted_holder_revokable_script.0 == outp.script_pubkey {
spendable_outputs.push(SpendableOutputDescriptor::DelayedPaymentOutput(DelayedPaymentOutputDescriptor {
- outpoint: OutPoint { txid: tx.txid(), index: i as u16 },
+ outpoint: OutPoint { txid: tx.compute_txid(), index: i as u16 },
per_commitment_point: broadcasted_holder_revokable_script.1,
to_self_delay: self.on_holder_tx_csv,
output: outp.clone(),
}
if self.counterparty_payment_script == outp.script_pubkey {
spendable_outputs.push(SpendableOutputDescriptor::StaticPaymentOutput(StaticPaymentOutputDescriptor {
- outpoint: OutPoint { txid: tx.txid(), index: i as u16 },
+ outpoint: OutPoint { txid: tx.compute_txid(), index: i as u16 },
output: outp.clone(),
channel_keys_id: self.channel_keys_id,
channel_value_satoshis: self.channel_value_satoshis,
}
if self.shutdown_script.as_ref() == Some(&outp.script_pubkey) {
spendable_outputs.push(SpendableOutputDescriptor::StaticOutput {
- outpoint: OutPoint { txid: tx.txid(), index: i as u16 },
+ outpoint: OutPoint { txid: tx.compute_txid(), index: i as u16 },
output: outp.clone(),
channel_keys_id: Some(self.channel_keys_id),
});
) where L::Target: Logger {
for spendable_output in self.get_spendable_outputs(tx) {
let entry = OnchainEventEntry {
- txid: tx.txid(),
+ txid: tx.compute_txid(),
transaction: Some(tx.clone()),
height,
block_hash: Some(*block_hash),
assert!(txn_broadcasted.len() >= 2);
let htlc_txn = txn_broadcasted.iter().filter(|tx| {
assert_eq!(tx.input.len(), 1);
- tx.input[0].previous_output.txid == broadcast_tx.txid()
+ tx.input[0].previous_output.txid == broadcast_tx.compute_txid()
}).collect::<Vec<_>>();
assert_eq!(htlc_txn.len(), 2);
check_spends!(htlc_txn[0], broadcast_tx);
log_info!(logger, "{} onchain {}", log_start, log_tx!(tx.0));
broadcaster.broadcast_transactions(&[&tx.0]);
} else {
- log_info!(logger, "Waiting for signature of unsigned onchain transaction {}", tx.0.txid());
+ log_info!(logger, "Waiting for signature of unsigned onchain transaction {}", tx.0.compute_txid());
}
},
OnchainClaim::Event(event) => {
}
}
- /// Returns true if we are currently tracking any pending claim requests that are not fully
+ /// Returns true if we are currently tracking any pending claim requests that are not fully
/// confirmed yet.
pub(super) fn has_pending_claims(&self) -> bool
{
let predicted_weight = cached_request.package_weight(&self.destination_script);
if let Some((output_value, new_feerate)) = cached_request.compute_package_output(
- predicted_weight, self.destination_script.dust_value().to_sat(),
+ predicted_weight, self.destination_script.minimal_non_dust().to_sat(),
feerate_strategy, fee_estimator, logger,
) {
assert!(new_feerate != 0);
// Commitment inputs with anchors support are the only untractable inputs supported
// thus far that require external funding.
PackageSolvingData::HolderFundingOutput(output) => {
- debug_assert_eq!(tx.0.txid(), self.holder_commitment.trust().txid(),
+ debug_assert_eq!(tx.0.compute_txid(), self.holder_commitment.trust().txid(),
"Holder commitment transaction mismatch");
let conf_target = ConfirmationTarget::OnChainSweep;
compute_feerate_sat_per_1000_weight(fee_sat, tx.0.weight().to_wu());
if commitment_tx_feerate_sat_per_1000_weight >= package_target_feerate_sat_per_1000_weight {
log_debug!(logger, "Pre-signed commitment {} already has feerate {} sat/kW above required {} sat/kW",
- tx.0.txid(), commitment_tx_feerate_sat_per_1000_weight,
+ tx.0.compute_txid(), commitment_tx_feerate_sat_per_1000_weight,
package_target_feerate_sat_per_1000_weight);
return Some((new_timer, 0, OnchainClaim::Tx(tx.clone())));
}
log_info!(logger, "Broadcasting onchain {}", log_tx!(tx.0));
broadcaster.broadcast_transactions(&[&tx.0]);
} else {
- log_info!(logger, "Waiting for signature of unsigned onchain transaction {}", tx.0.txid());
+ log_info!(logger, "Waiting for signature of unsigned onchain transaction {}", tx.0.compute_txid());
}
- ClaimId(tx.0.txid().to_byte_array())
+ ClaimId(tx.0.compute_txid().to_byte_array())
},
OnchainClaim::Event(claim_event) => {
log_info!(logger, "Yielding onchain event to spend inputs {:?}", req.outpoints());
ClaimEvent::BumpCommitment { ref commitment_tx, .. } =>
// For commitment claims, we can just use their txid as it should
// already be unique.
- ClaimId(commitment_tx.txid().to_byte_array()),
+ ClaimId(commitment_tx.compute_txid().to_byte_array()),
ClaimEvent::BumpHTLC { ref htlcs, .. } => {
// For HTLC claims, commit to the entire set of HTLC outputs to
// claim, which will always be unique per request. Once a claim ID
macro_rules! clean_claim_request_after_safety_delay {
() => {
let entry = OnchainEventEntry {
- txid: tx.txid(),
+ txid: tx.compute_txid(),
height: conf_height,
block_hash: Some(conf_hash),
event: OnchainEvent::Claim { claim_id: *claim_id }
}
for package in claimed_outputs_material.drain(..) {
let entry = OnchainEventEntry {
- txid: tx.txid(),
+ txid: tx.compute_txid(),
height: conf_height,
block_hash: Some(conf_hash),
event: OnchainEvent::ContentiousOutpoint { package },
broadcaster.broadcast_transactions(&[&bump_tx.0]);
} else {
log_info!(logger, "Waiting for signature of RBF-bumped unsigned onchain transaction {}",
- bump_tx.0.txid());
+ bump_tx.0.compute_txid());
}
},
OnchainClaim::Event(claim_event) => {
log_info!(logger, "Broadcasting onchain {}", log_tx!(bump_tx.0));
broadcaster.broadcast_transactions(&[&bump_tx.0]);
} else {
- log_info!(logger, "Waiting for signature of unsigned onchain transaction {}", bump_tx.0.txid());
+ log_info!(logger, "Waiting for signature of unsigned onchain transaction {}", bump_tx.0.compute_txid());
}
},
OnchainClaim::Event(claim_event) => {
fn test_channel_id_calculation() {
let tx: Transaction = encode::deserialize(&<Vec<u8>>::from_hex("020000000001010e0adef48412e4361325ac1c6e36411299ab09d4f083b9d8ddb55fbc06e1b0c00000000000feffffff0220a1070000000000220020f81d95e040bd0a493e38bae27bff52fe2bb58b93b293eb579c01c31b05c5af1dc072cfee54a3000016001434b1d6211af5551905dc2642d05f5b04d25a8fe80247304402207f570e3f0de50546aad25a872e3df059d277e776dda4269fa0d2cc8c2ee6ec9a022054e7fae5ca94d47534c86705857c24ceea3ad51c69dd6051c5850304880fc43a012103cb11a1bacc223d98d91f1946c6752e358a5eb1a1c983b3e6fb15378f453b76bd00000000").unwrap()[..]).unwrap();
assert_eq!(&ChannelId::v1_from_funding_outpoint(OutPoint {
- txid: tx.txid(),
+ txid: tx.compute_txid(),
index: 0
}).0[..], &<Vec<u8>>::from_hex("3e88dd7165faf7be58b3c5bb2c9c452aebef682807ea57080f62e6f6e113c25e").unwrap()[..]);
assert_eq!(&ChannelId::v1_from_funding_outpoint(OutPoint {
- txid: tx.txid(),
+ txid: tx.compute_txid(),
index: 1
}).0[..], &<Vec<u8>>::from_hex("3e88dd7165faf7be58b3c5bb2c9c452aebef682807ea57080f62e6f6e113c25f").unwrap()[..]);
}
WITNESS_SCALE_FACTOR as u64,
);
let change_output_amount = Amount::from_sat(remaining_amount.to_sat().saturating_sub(change_output_fee));
- let change_output = if change_output_amount < change_script.dust_value() {
+ let change_output = if change_output_amount < change_script.minimal_non_dust() {
log_debug!(self.logger, "Coin selection attempt did not yield change output");
None
} else {
coin_selection.confirmed_utxos.iter().map(|utxo| utxo.output.value).sum();
self.process_coin_selection(&mut anchor_tx, &coin_selection);
- let anchor_txid = anchor_tx.txid();
+ let anchor_txid = anchor_tx.compute_txid();
// construct psbt
let mut anchor_psbt = Psbt::from_unsigned_tx(anchor_tx).unwrap();
}
log_info!(self.logger, "Broadcasting anchor transaction {} to bump channel close with txid {}",
- anchor_txid, commitment_tx.txid());
+ anchor_txid, commitment_tx.compute_txid());
self.broadcaster.broadcast_transactions(&[&commitment_tx, &anchor_tx]);
Ok(())
}
#[cfg(debug_assertions)]
let unsigned_tx_weight = htlc_psbt.unsigned_tx.weight().to_wu() - (htlc_psbt.unsigned_tx.input.len() as u64 * EMPTY_SCRIPT_SIG_WEIGHT);
- log_debug!(self.logger, "Signing HTLC transaction {}", htlc_psbt.unsigned_tx.txid());
+ log_debug!(self.logger, "Signing HTLC transaction {}", htlc_psbt.unsigned_tx.compute_txid());
htlc_tx = self.utxo_source.sign_psbt(htlc_psbt)?;
let mut signers = BTreeMap::new();
commitment_tx_fee_satoshis, anchor_descriptor, ..
} => {
log_info!(self.logger, "Handling channel close bump (claim_id = {}, commitment_txid = {})",
- log_bytes!(claim_id.0), commitment_tx.txid());
+ log_bytes!(claim_id.0), commitment_tx.compute_txid());
if let Err(_) = self.handle_channel_close(
*claim_id, *package_target_feerate_sat_per_1000_weight, commitment_tx,
*commitment_tx_fee_satoshis, anchor_descriptor,
) {
log_error!(self.logger, "Failed bumping commitment transaction fee for {}",
- commitment_tx.txid());
+ commitment_tx.compute_txid());
}
}
BumpTransactionEvent::HTLCResolution {
Ok(count)
}
- pub fn read_to_end<D: Read>(mut d: &mut D) -> Result<alloc::vec::Vec<u8>, io::Error> {
+ pub fn read_to_end<D: Read>(d: &mut D) -> Result<alloc::vec::Vec<u8>, io::Error> {
let mut result = vec![];
let mut buf = [0u8; 64];
loop {
if anchors {
*nodes[0].fee_estimator.sat_per_kw.lock().unwrap() *= 2;
*nodes[1].fee_estimator.sat_per_kw.lock().unwrap() *= 2;
- closing_node.wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 }, coinbase_tx.output[0].value);
+ closing_node.wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 }, coinbase_tx.output[0].value);
}
// Route an HTLC and set the signer as unavailable.
txn.remove(0)
} else {
assert_eq!(txn.len(), 2);
- if txn[0].input[0].previous_output.txid == funding_tx.txid() {
+ if txn[0].input[0].previous_output.txid == funding_tx.compute_txid() {
check_spends!(txn[0], funding_tx);
check_spends!(txn[1], txn[0]);
txn.remove(0)
let (obscured_commitment_transaction_number, txins) = Self::internal_build_inputs(commitment_number, channel_parameters);
let transaction = Self::make_transaction(obscured_commitment_transaction_number, txins, outputs);
- let txid = transaction.txid();
+ let txid = transaction.compute_txid();
CommitmentTransaction {
commitment_number,
to_broadcaster_value_sat,
let (outputs, _) = Self::internal_build_outputs(keys, self.to_broadcaster_value_sat, self.to_countersignatory_value_sat, &mut htlcs_with_aux, channel_parameters, broadcaster_funding_key, countersignatory_funding_key)?;
let transaction = Self::make_transaction(obscured_commitment_transaction_number, txins, outputs);
- let txid = transaction.txid();
+ let txid = transaction.compute_txid();
let built_transaction = BuiltCommitmentTransaction {
transaction,
txid
let justice_tx = tx.trust().build_to_local_justice_tx(253, destination_script.clone()).unwrap();
assert_eq!(justice_tx.input.len(), 1);
- assert_eq!(justice_tx.input[0].previous_output.txid, tx.built.transaction.txid());
+ assert_eq!(justice_tx.input[0].previous_output.txid, tx.built.transaction.compute_txid());
assert_eq!(justice_tx.input[0].previous_output.vout, tx.trust().revokeable_output_index().unwrap() as u32);
assert!(justice_tx.input[0].sequence.is_rbf());
// Create some initial channel
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
- let outpoint = OutPoint { txid: chan.3.txid(), index: 0 };
+ let outpoint = OutPoint { txid: chan.3.compute_txid(), index: 0 };
// Rebalance the network to generate htlc in the two directions
send_payment(&nodes[0], &vec!(&nodes[1])[..], 10_000_000);
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 0);
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().len(), 1);
- assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0)[0].txid(), funding_output.txid);
+ assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0)[0].compute_txid(), funding_output.txid);
if confirm_a_first {
confirm_transaction(&nodes[0], &funding_tx);
// Check if the transaction is the expected funding transaction, and if it is,
// check that it pays the right amount to the right script.
if self.context.funding_tx_confirmation_height == 0 {
- if tx.txid() == funding_txo.txid {
+ if tx.compute_txid() == funding_txo.txid {
let txo_idx = funding_txo.index as usize;
if txo_idx >= tx.output.len() || tx.output[txo_idx].script_pubkey != self.context.get_funding_redeemscript().to_p2wsh() ||
tx.output[txo_idx].value.to_sat() != self.context.channel_value_satoshis {
}
for inp in tx.input.iter() {
if inp.previous_output == funding_txo.into_bitcoin_outpoint() {
- log_info!(logger, "Detected channel-closing tx {} spending {}:{}, closing channel {}", tx.txid(), inp.previous_output.txid, inp.previous_output.vout, &self.context.channel_id());
+ log_info!(logger, "Detected channel-closing tx {} spending {}:{}, closing channel {}", tx.compute_txid(), inp.previous_output.txid, inp.previous_output.vout, &self.context.channel_id());
return Err(ClosureReason::CommitmentTxConfirmed);
}
}
let tx = Transaction { version: Version::ONE, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
value: Amount::from_sat(10000000), script_pubkey: output_script.clone(),
}]};
- let funding_outpoint = OutPoint{ txid: tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint{ txid: tx.compute_txid(), index: 0 };
let funding_created_msg = node_a_chan.get_funding_created(tx.clone(), funding_outpoint, false, &&logger).map_err(|_| ()).unwrap();
let (_, funding_signed_msg, _) = node_b_chan.funding_created(&funding_created_msg.unwrap(), best_block, &&keys_provider, &&logger).map_err(|_| ()).unwrap();
let tx = Transaction { version: Version::ONE, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
value: Amount::from_sat(10000000), script_pubkey: output_script.clone(),
}]};
- let funding_outpoint = OutPoint{ txid: tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint{ txid: tx.compute_txid(), index: 0 };
let funding_created_msg = node_a_chan.get_funding_created(tx.clone(), funding_outpoint, false, &&logger).map_err(|_| ()).unwrap();
let (mut node_b_chan, funding_signed_msg, _) = node_b_chan.funding_created(&funding_created_msg.unwrap(), best_block, &&keys_provider, &&logger).map_err(|_| ()).unwrap();
let tx = Transaction { version: Version::ONE, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
value: Amount::from_sat(10000000), script_pubkey: output_script.clone(),
}]};
- let funding_outpoint = OutPoint{ txid: tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint{ txid: tx.compute_txid(), index: 0 };
let funding_created_msg = node_a_chan.get_funding_created(tx.clone(), funding_outpoint, false, &&logger).map_err(|_| ()).unwrap();
let (_, funding_signed_msg, _) = node_b_chan.funding_created(&funding_created_msg.unwrap(), best_block, &&keys_provider, &&logger).map_err(|_| ()).unwrap();
let tx = Transaction { version: Version::ONE, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
value: Amount::from_sat(10000000), script_pubkey: outbound_chan.context.get_funding_redeemscript(),
}]};
- let funding_outpoint = OutPoint{ txid: tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint{ txid: tx.compute_txid(), index: 0 };
let funding_created = outbound_chan.get_funding_created(tx.clone(), funding_outpoint, false, &&logger).map_err(|_| ()).unwrap().unwrap();
let mut chan = match inbound_chan.funding_created(&funding_created, best_block, &&keys_provider, &&logger) {
Ok((chan, _, _)) => chan,
value: Amount::from_sat(10000000), script_pubkey: Builder::new().into_script(),
},
]};
- let funding_outpoint = OutPoint{ txid: tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint{ txid: tx.compute_txid(), index: 0 };
let funding_created_msg = node_a_chan.get_funding_created(
tx.clone(), funding_outpoint, true, &&logger,
).map_err(|_| ()).unwrap();
impl FundingType {
fn txid(&self) -> Txid {
match self {
- FundingType::Checked(tx) => tx.txid(),
+ FundingType::Checked(tx) => tx.compute_txid(),
FundingType::Unchecked(outp) => outp.txid,
}
}
}
}
if let Some(tx) = batch_funding_tx {
- log_info!($self.logger, "Broadcasting batch funding transaction with txid {}", tx.txid());
+ log_info!($self.logger, "Broadcasting batch funding transaction with txid {}", tx.compute_txid());
$self.tx_broadcaster.broadcast_transactions(&[&tx]);
}
}
#[cfg(test)]
pub(crate) fn funding_transaction_generated_unchecked(&self, temporary_channel_id: ChannelId, counterparty_node_id: PublicKey, funding_transaction: Transaction, output_index: u16) -> Result<(), APIError> {
- let txid = funding_transaction.txid();
+ let txid = funding_transaction.compute_txid();
self.funding_transaction_generated_intern(temporary_channel_id, counterparty_node_id, funding_transaction, false, |_| {
Ok(OutPoint { txid, index: output_index })
}, false)
if let Some(tx) = funding_broadcastable {
if channel.context.is_manual_broadcast() {
- log_info!(logger, "Not broadcasting funding transaction with txid {} as it is manually managed", tx.txid());
+ log_info!(logger, "Not broadcasting funding transaction with txid {} as it is manually managed", tx.compute_txid());
let mut pending_events = self.pending_events.lock().unwrap();
match channel.context.get_funding_txo() {
Some(funding_txo) => {
}
};
} else {
- log_info!(logger, "Broadcasting funding transaction with txid {}", tx.txid());
+ log_info!(logger, "Broadcasting funding transaction with txid {}", tx.compute_txid());
self.tx_broadcaster.broadcast_transactions(&[&tx]);
}
}
nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), &accept_channel);
let (temporary_channel_id, tx, funding_output) = create_funding_transaction(&nodes[0], &nodes[1].node.get_our_node_id(), 1_000_000, 42);
- let channel_id = ChannelId::from_bytes(tx.txid().to_byte_array());
+ let channel_id = ChannelId::from_bytes(tx.compute_txid().to_byte_array());
{
// Ensure that the `outpoint_to_peer` map is empty until either party has received the
// funding transaction, and have the real `channel_id`.
let wallet_script = node.wallet_source.get_change_script().unwrap();
for (idx, output) in tx.output.iter().enumerate() {
if output.script_pubkey == wallet_script {
- let outpoint = bitcoin::OutPoint { txid: tx.txid(), vout: idx as u32 };
+ let outpoint = bitcoin::OutPoint { txid: tx.compute_txid(), vout: idx as u32 };
node.wallet_source.add_utxo(outpoint, output.value);
}
}
},
ConnectStyle::BestBlockFirstReorgsOnlyTip|ConnectStyle::TransactionsFirstReorgsOnlyTip => {
for tx in orig.0.txdata {
- node.chain_monitor.chain_monitor.transaction_unconfirmed(&tx.txid());
- node.node.transaction_unconfirmed(&tx.txid());
+ node.chain_monitor.chain_monitor.transaction_unconfirmed(&tx.compute_txid());
+ node.node.transaction_unconfirmed(&tx.compute_txid());
}
},
_ => {
let tx = Transaction { version: transaction::Version(chan_id as i32), lock_time: LockTime::ZERO, input, output: vec![TxOut {
value: Amount::from_sat(*channel_value_satoshis), script_pubkey: output_script.clone(),
}]};
- let funding_outpoint = OutPoint { txid: tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint { txid: tx.compute_txid(), index: 0 };
(*temporary_channel_id, tx, funding_outpoint)
},
_ => panic!("Unexpected event"),
pub fn do_check_spends<F: Fn(&bitcoin::transaction::OutPoint) -> Option<TxOut>>(tx: &Transaction, get_output: F) {
for outp in tx.output.iter() {
- assert!(outp.value >= outp.script_pubkey.dust_value(), "Spending tx output didn't meet dust limit");
+ assert!(outp.value >= outp.script_pubkey.minimal_non_dust(), "Spending tx output didn't meet dust limit");
}
let mut total_value_in = 0;
for input in tx.input.iter() {
{
$(
for outp in $spends_txn.output.iter() {
- assert!(outp.value >= outp.script_pubkey.dust_value(), "Input tx output didn't meet dust limit");
+ assert!(outp.value >= outp.script_pubkey.minimal_non_dust(), "Input tx output didn't meet dust limit");
}
)*
let get_output = |out_point: &bitcoin::transaction::OutPoint| {
$(
- if out_point.txid == $spends_txn.txid() {
+ if out_point.txid == $spends_txn.compute_txid() {
return $spends_txn.output.get(out_point.vout as usize).cloned()
}
)*
pub fn test_txn_broadcast<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, chan: &(msgs::ChannelUpdate, msgs::ChannelUpdate, ChannelId, Transaction), commitment_tx: Option<Transaction>, has_htlc_tx: HTLCType) -> Vec<Transaction> {
let mut node_txn = node.tx_broadcaster.txn_broadcasted.lock().unwrap();
let mut txn_seen = new_hash_set();
- node_txn.retain(|tx| txn_seen.insert(tx.txid()));
+ node_txn.retain(|tx| txn_seen.insert(tx.compute_txid()));
assert!(node_txn.len() >= if commitment_tx.is_some() { 0 } else { 1 } + if has_htlc_tx == HTLCType::NONE { 0 } else { 1 });
let mut res = Vec::with_capacity(2);
node_txn.retain(|tx| {
- if tx.input.len() == 1 && tx.input[0].previous_output.txid == chan.3.txid() {
+ if tx.input.len() == 1 && tx.input[0].previous_output.txid == chan.3.compute_txid() {
check_spends!(tx, chan.3);
if commitment_tx.is_none() {
res.push(tx.clone());
if has_htlc_tx != HTLCType::NONE {
node_txn.retain(|tx| {
- if tx.input.len() == 1 && tx.input[0].previous_output.txid == res[0].txid() {
+ if tx.input.len() == 1 && tx.input[0].previous_output.txid == res[0].compute_txid() {
check_spends!(tx, res[0]);
if has_htlc_tx == HTLCType::TIMEOUT {
assert_ne!(tx.lock_time, LockTime::ZERO);
// for revoked htlc outputs
if node_txn.len() != 1 && node_txn.len() != 2 && node_txn.len() != 3 { assert!(false); }
node_txn.retain(|tx| {
- if tx.input.len() == 1 && tx.input[0].previous_output.txid == revoked_tx.txid() {
+ if tx.input.len() == 1 && tx.input[0].previous_output.txid == revoked_tx.compute_txid() {
check_spends!(tx, revoked_tx);
false
} else { true }
pub fn check_preimage_claim<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, prev_txn: &Vec<Transaction>) -> Vec<Transaction> {
let mut node_txn = node.tx_broadcaster.txn_broadcasted.lock().unwrap();
let mut txn_seen = new_hash_set();
- node_txn.retain(|tx| txn_seen.insert(tx.txid()));
+ node_txn.retain(|tx| txn_seen.insert(tx.compute_txid()));
let mut found_prev = false;
for prev_tx in prev_txn {
for tx in &*node_txn {
- if tx.input[0].previous_output.txid == prev_tx.txid() {
+ if tx.input[0].previous_output.txid == prev_tx.compute_txid() {
check_spends!(tx, prev_tx);
let mut iter = tx.input[0].witness.iter();
iter.next().expect("expected 3 witness items");
let node_txn = test_txn_broadcast(&nodes[2], &chan_3, None, HTLCType::NONE);
connect_blocks(&nodes[2], TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS + MIN_CLTV_EXPIRY_DELTA as u32 + 1);
test_txn_broadcast(&nodes[2], &chan_3, None, HTLCType::TIMEOUT);
- node2_commitment_txid = node_txn[0].txid();
+ node2_commitment_txid = node_txn[0].compute_txid();
// Claim the payment on nodes[3], giving it knowledge of the preimage
claim_funds!(nodes[3], nodes[2], payment_preimage_1, payment_hash_1);
// Drop the ChannelMonitor for the previous channel to avoid it broadcasting transactions and
// confusing us in the following tests.
- let chan_3_mon = nodes[3].chain_monitor.chain_monitor.remove_monitor(&OutPoint { txid: chan_3.3.txid(), index: 0 });
+ let chan_3_mon = nodes[3].chain_monitor.chain_monitor.remove_monitor(&OutPoint { txid: chan_3.3.compute_txid(), index: 0 });
// One pending HTLC to time out:
let (payment_preimage_2, payment_hash_2, ..) = route_payment(&nodes[3], &[&nodes[4]], 3_000_000);
assert_eq!(nodes[3].node.list_channels().len(), 0);
assert_eq!(nodes[4].node.list_channels().len(), 0);
- assert_eq!(nodes[3].chain_monitor.chain_monitor.watch_channel(OutPoint { txid: chan_3.3.txid(), index: 0 }, chan_3_mon),
+ assert_eq!(nodes[3].chain_monitor.chain_monitor.watch_channel(OutPoint { txid: chan_3.3.compute_txid(), index: 0 }, chan_3_mon),
Ok(ChannelMonitorUpdateStatus::Completed));
check_closed_event!(nodes[3], 1, ClosureReason::HTLCsTimedOut, [nodes[4].node.get_our_node_id()], 100000);
}
let revoked_local_txn = get_local_commitment_txn!(nodes[0], chan_5.2);
assert_eq!(revoked_local_txn.len(), 2); // First commitment tx, then HTLC tx
assert_eq!(revoked_local_txn[0].input.len(), 1);
- assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_5.3.txid());
+ assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_5.3.compute_txid());
assert_eq!(revoked_local_txn[0].output.len(), 2); // Only HTLC and output back to 0 are present
assert_eq!(revoked_local_txn[1].input.len(), 1);
- assert_eq!(revoked_local_txn[1].input[0].previous_output.txid, revoked_local_txn[0].txid());
+ assert_eq!(revoked_local_txn[1].input[0].previous_output.txid, revoked_local_txn[0].compute_txid());
assert_eq!(revoked_local_txn[1].input[0].witness.last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT); // HTLC-Timeout
// Revoke the old state
claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage_3);
let revoked_local_txn = get_local_commitment_txn!(nodes[1], chan_6.2);
assert_eq!(revoked_local_txn.len(), 1); // Only commitment tx
assert_eq!(revoked_local_txn[0].input.len(), 1);
- assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_6.3.txid());
+ assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_6.3.compute_txid());
assert_eq!(revoked_local_txn[0].output.len(), 2); // Only HTLC and output back to A are present
// Revoke the old state
claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage_4);
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let (_, _, channel_id, funding_tx) = create_announced_chan_between_nodes(&nodes, 0, 1);
- let funding_txo = OutPoint { txid: funding_tx.txid(), index: 0 };
+ let funding_txo = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
if !broadcast_initial_commitment {
// Send a payment to move the channel forward
// Send another payment, now revoking the previous commitment tx
send_payment(&nodes[0], &vec!(&nodes[1])[..], 5_000_000);
- let justice_tx = persisters[1].justice_tx(funding_txo, &revoked_commitment_tx.txid()).unwrap();
+ let justice_tx = persisters[1].justice_tx(funding_txo, &revoked_commitment_tx.compute_txid()).unwrap();
check_spends!(justice_tx, revoked_commitment_tx);
mine_transactions(&nodes[1], &[revoked_commitment_tx, &justice_tx]);
let revoked_local_txn = get_local_commitment_txn!(nodes[0], chan_1.2);
assert_eq!(revoked_local_txn.len(), 2); // commitment tx + 1 HTLC-Timeout tx
assert_eq!(revoked_local_txn[0].input.len(), 1);
- assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_1.3.txid());
+ assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_1.3.compute_txid());
assert_eq!(revoked_local_txn[1].input.len(), 1);
- assert_eq!(revoked_local_txn[1].input[0].previous_output.txid, revoked_local_txn[0].txid());
+ assert_eq!(revoked_local_txn[1].input[0].previous_output.txid, revoked_local_txn[0].compute_txid());
assert_eq!(revoked_local_txn[1].input[0].witness.last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT); // HTLC-Timeout
check_spends!(revoked_local_txn[1], revoked_local_txn[0]);
check_spends!(node_txn[1], node_txn[0]);
// Filter out any non justice transactions.
- node_txn.retain(|tx| tx.input[0].previous_output.txid == revoked_local_txn[0].txid());
+ node_txn.retain(|tx| tx.input[0].previous_output.txid == revoked_local_txn[0].compute_txid());
assert!(node_txn.len() > 3);
assert_eq!(node_txn[0].input.len(), 1);
{
let mut added_monitors = nodes[1].chain_monitor.added_monitors.lock().unwrap();
assert_eq!(added_monitors.len(), 1);
- assert_eq!(added_monitors[0].0.txid, chan_2.3.txid());
+ assert_eq!(added_monitors[0].0.txid, chan_2.3.compute_txid());
added_monitors.clear();
}
let forwarded_events = nodes[1].node.get_and_clear_pending_events();
{
let mut added_monitors = nodes[1].chain_monitor.added_monitors.lock().unwrap();
assert_eq!(added_monitors.len(), 2);
- assert_eq!(added_monitors[0].0.txid, chan_1.3.txid());
- assert_eq!(added_monitors[1].0.txid, chan_1.3.txid());
+ assert_eq!(added_monitors[0].0.txid, chan_1.3.compute_txid());
+ assert_eq!(added_monitors[1].0.txid, chan_1.3.compute_txid());
added_monitors.clear();
}
assert_eq!(events.len(), 3);
} else {
// Certain `ConnectStyle`s will cause RBF bumps of the previous HTLC transaction to be broadcast.
// FullBlockViaListen
- if node_txn[0].input[0].previous_output.txid == node_a_commitment_tx[0].txid() {
+ if node_txn[0].input[0].previous_output.txid == node_a_commitment_tx[0].compute_txid() {
check_spends!(node_txn[1], commitment_tx[0]);
check_spends!(node_txn[2], commitment_tx[0]);
assert_ne!(node_txn[1].input[0].previous_output.vout, node_txn[2].input[0].previous_output.vout);
assert_eq!(node_txn.len(), if nodes[2].connect_style.borrow().updates_best_block_first() { 2 } else { 1 });
let htlc_tx = node_txn.pop().unwrap();
assert_eq!(htlc_tx.input.len(), 1);
- assert_eq!(htlc_tx.input[0].previous_output.txid, commitment_tx.txid());
+ assert_eq!(htlc_tx.input[0].previous_output.txid, commitment_tx.compute_txid());
assert_eq!(htlc_tx.lock_time, LockTime::ZERO); // Must be an HTLC-Success
assert_eq!(htlc_tx.input[0].witness.len(), 5); // Must be an HTLC-Success
let payment_preimage = route_payment(&nodes[0], &vec!(&nodes[1])[..], 3000000).0;
let revoked_local_txn = get_local_commitment_txn!(nodes[0], chan.2);
assert_eq!(revoked_local_txn[0].input.len(), 1);
- assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan.3.txid());
+ assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan.3.compute_txid());
claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage);
mine_transaction(&nodes[1], &revoked_local_txn[0]);
let commitment_tx = get_local_commitment_txn!(nodes[0], chan_1.2);
assert_eq!(commitment_tx[0].input.len(), 1);
- assert_eq!(commitment_tx[0].input[0].previous_output.txid, chan_1.3.txid());
+ assert_eq!(commitment_tx[0].input[0].previous_output.txid, chan_1.3.compute_txid());
// Settle A's commitment tx on B's chain
nodes[1].node.claim_funds(payment_preimage);
let commitment_tx = get_local_commitment_txn!(nodes[0], chan_1.2);
assert_eq!(commitment_tx[0].input.len(), 1);
- assert_eq!(commitment_tx[0].input[0].previous_output.txid, chan_1.3.txid());
+ assert_eq!(commitment_tx[0].input[0].previous_output.txid, chan_1.3.compute_txid());
// Settle A's commitment tx on B' chain
mine_transaction(&nodes[1], &commitment_tx[0]);
let payment_preimage = route_payment(&nodes[0], &vec!(&nodes[1])[..], 3000000).0;
let revoked_local_txn = get_local_commitment_txn!(nodes[0], chan_1.2);
assert_eq!(revoked_local_txn[0].input.len(), 1);
- assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_1.3.txid());
+ assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_1.3.compute_txid());
claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage);
let payment_preimage = route_payment(&nodes[0], &vec!(&nodes[1])[..], 3000000).0;
let revoked_local_txn = get_local_commitment_txn!(nodes[0], chan_1.2);
assert_eq!(revoked_local_txn[0].input.len(), 1);
- assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_1.3.txid());
+ assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_1.3.compute_txid());
claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage);
assert_eq!(node_txn[1].input.len(), 2);
check_spends!(node_txn[1], revoked_local_txn[0], revoked_htlc_txn[0]);
- if node_txn[1].input[1].previous_output.txid == revoked_htlc_txn[0].txid() {
+ if node_txn[1].input[1].previous_output.txid == revoked_htlc_txn[0].compute_txid() {
assert_ne!(node_txn[1].input[0].previous_output, revoked_htlc_txn[0].input[0].previous_output);
} else {
- assert_eq!(node_txn[1].input[0].previous_output.txid, revoked_htlc_txn[0].txid());
+ assert_eq!(node_txn[1].input[0].previous_output.txid, revoked_htlc_txn[0].compute_txid());
assert_ne!(node_txn[1].input[1].previous_output, revoked_htlc_txn[0].input[0].previous_output);
}
let payment_preimage = route_payment(&nodes[0], &vec!(&nodes[1])[..], 3000000).0;
let revoked_local_txn = get_local_commitment_txn!(nodes[1], chan_1.2);
assert_eq!(revoked_local_txn[0].input.len(), 1);
- assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_1.3.txid());
+ assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_1.3.compute_txid());
// The to-be-revoked commitment tx should have one HTLC and one to_remote output
assert_eq!(revoked_local_txn[0].output.len(), 2);
// transactions next...
assert_eq!(node_txn[0].input.len(), 2);
check_spends!(node_txn[0], revoked_local_txn[0], revoked_htlc_txn[0]);
- if node_txn[0].input[1].previous_output.txid == revoked_htlc_txn[0].txid() {
+ if node_txn[0].input[1].previous_output.txid == revoked_htlc_txn[0].compute_txid() {
assert_eq!(node_txn[0].input[0].previous_output, revoked_htlc_txn[0].input[0].previous_output);
} else {
- assert_eq!(node_txn[0].input[0].previous_output.txid, revoked_htlc_txn[0].txid());
+ assert_eq!(node_txn[0].input[0].previous_output.txid, revoked_htlc_txn[0].compute_txid());
assert_eq!(node_txn[0].input[1].previous_output, revoked_htlc_txn[0].input[0].previous_output);
}
connect_blocks(&nodes[0], TEST_FINAL_CLTV); // Confirm blocks until the HTLC expires
timeout_tx = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().drain(..)
- .filter(|tx| tx.input[0].previous_output.txid == bs_commitment_tx[0].txid()).collect();
+ .filter(|tx| tx.input[0].previous_output.txid == bs_commitment_tx[0].compute_txid()).collect();
check_spends!(timeout_tx[0], bs_commitment_tx[0]);
// For both a revoked or non-revoked commitment transaction, after ANTI_REORG_DELAY the
// dust HTLC should have been failed.
// Revoked commitment txn with 4 outputs : to_local, to_remote, 1 outgoing HTLC, 1 incoming HTLC
assert_eq!(revoked_txn[0].output.len(), 4);
assert_eq!(revoked_txn[0].input.len(), 1);
- assert_eq!(revoked_txn[0].input[0].previous_output.txid, chan.3.txid());
- let revoked_txid = revoked_txn[0].txid();
+ assert_eq!(revoked_txn[0].input[0].previous_output.txid, chan.3.compute_txid());
+ let revoked_txid = revoked_txn[0].compute_txid();
let mut penalty_sum = 0;
for outp in revoked_txn[0].output.iter() {
check_spends!(node_txn[0], revoked_txn[0]);
let fee_1 = penalty_sum - node_txn[0].output[0].value.to_sat();
feerate_1 = fee_1 * 1000 / node_txn[0].weight().to_wu();
- penalty_1 = node_txn[0].txid();
+ penalty_1 = node_txn[0].compute_txid();
node_txn.clear();
};
assert_eq!(node_txn[0].input.len(), 3); // Penalty txn claims to_local, offered_htlc and received_htlc outputs
assert_eq!(node_txn[0].output.len(), 1);
check_spends!(node_txn[0], revoked_txn[0]);
- penalty_2 = node_txn[0].txid();
+ penalty_2 = node_txn[0].compute_txid();
// Verify new bumped tx is different from last claiming transaction, we don't want spurrious rebroadcast
assert_ne!(penalty_2, penalty_1);
let fee_2 = penalty_sum - node_txn[0].output[0].value.to_sat();
assert_eq!(node_txn[0].input.len(), 3); // Penalty txn claims to_local, offered_htlc and received_htlc outputs
assert_eq!(node_txn[0].output.len(), 1);
check_spends!(node_txn[0], revoked_txn[0]);
- penalty_3 = node_txn[0].txid();
+ penalty_3 = node_txn[0].compute_txid();
// Verify new bumped tx is different from last claiming transaction, we don't want spurrious rebroadcast
assert_ne!(penalty_3, penalty_2);
let fee_3 = penalty_sum - node_txn[0].output[0].value.to_sat();
let revoked_local_txn = get_local_commitment_txn!(nodes[1], chan.2);
assert_eq!(revoked_local_txn[0].input.len(), 1);
- assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan.3.txid());
+ assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan.3.compute_txid());
// Revoke local commitment tx
claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage);
assert_eq!(node_txn[3].output.len(), 1);
check_spends!(node_txn[3], revoked_htlc_txn[0], revoked_htlc_txn[1]);
- first = node_txn[3].txid();
+ first = node_txn[3].compute_txid();
// Store both feerates for later comparison
let fee_1 = revoked_htlc_txn[0].output[0].value + revoked_htlc_txn[1].output[0].value - node_txn[3].output[0].value;
feerate_1 = fee_1 * 1000 / node_txn[3].weight().to_wu();
assert_eq!(node_txn[0].input.len(), 2);
check_spends!(node_txn[0], revoked_htlc_txn[0], revoked_htlc_txn[1]);
// Verify bumped tx is different and 25% bump heuristic
- assert_ne!(first, node_txn[0].txid());
+ assert_ne!(first, node_txn[0].compute_txid());
let fee_2 = revoked_htlc_txn[0].output[0].value + revoked_htlc_txn[1].output[0].value - node_txn[0].output[0].value;
let feerate_2 = fee_2 * 1000 / node_txn[0].weight().to_wu();
assert!(feerate_2 * 100 > feerate_1 * 125);
let remote_txn = get_local_commitment_txn!(nodes[0], chan.2);
assert_eq!(remote_txn[0].output.len(), 4);
assert_eq!(remote_txn[0].input.len(), 1);
- assert_eq!(remote_txn[0].input[0].previous_output.txid, chan.3.txid());
+ assert_eq!(remote_txn[0].input[0].previous_output.txid, chan.3.compute_txid());
// Claim a HTLC without revocation (provide B monitor with preimage)
nodes[1].node.claim_funds(payment_preimage);
check_spends!(node_txn[1], remote_txn[0]);
check_spends!(node_txn[2], remote_txn[0]);
- preimage = node_txn[0].txid();
+ preimage = node_txn[0].compute_txid();
let index = node_txn[0].input[0].previous_output.vout;
let fee = remote_txn[0].output[index as usize].value.to_sat() - node_txn[0].output[0].value.to_sat();
feerate_preimage = fee * 1000 / node_txn[0].weight().to_wu();
check_spends!(preimage_bump, remote_txn[0]);
assert_eq!(node_txn[0].input[0].previous_output, preimage_bump.input[0].previous_output);
- timeout = timeout_tx.txid();
+ timeout = timeout_tx.compute_txid();
let index = timeout_tx.input[0].previous_output.vout;
let fee = remote_txn[0].output[index as usize].value.to_sat() - timeout_tx.output[0].value.to_sat();
feerate_timeout = fee * 1000 / timeout_tx.weight().to_wu();
let fee = remote_txn[0].output[index as usize].value.to_sat() - preimage_bump.output[0].value.to_sat();
let new_feerate = fee * 1000 / preimage_bump.weight().to_wu();
assert!(new_feerate * 100 > feerate_timeout * 125);
- assert_ne!(timeout, preimage_bump.txid());
+ assert_ne!(timeout, preimage_bump.compute_txid());
let index = node_txn[0].input[0].previous_output.vout;
let fee = remote_txn[0].output[index as usize].value.to_sat() - node_txn[0].output[0].value.to_sat();
let new_feerate = fee * 1000 / node_txn[0].weight().to_wu();
assert!(new_feerate * 100 > feerate_preimage * 125);
- assert_ne!(preimage, node_txn[0].txid());
+ assert_ne!(preimage, node_txn[0].compute_txid());
node_txn.clear();
}
let revoked_local_txn = get_local_commitment_txn!(nodes[1], chan.2);
assert_eq!(revoked_local_txn[0].input.len(), 1);
- assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan.3.txid());
+ assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan.3.compute_txid());
// Revoke local commitment tx
claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage_1);
connect_block(&nodes[0], &create_dummy_block(nodes[0].best_block_hash(), 42, penalty_txn));
connect_blocks(&nodes[0], ANTI_REORG_DELAY - 1);
{
- let monitor = nodes[0].chain_monitor.chain_monitor.get_monitor(OutPoint { txid: chan.3.txid(), index: 0 }).unwrap();
+ let monitor = nodes[0].chain_monitor.chain_monitor.get_monitor(OutPoint { txid: chan.3.compute_txid(), index: 0 }).unwrap();
assert!(monitor.inner.lock().unwrap().onchain_tx_handler.pending_claim_requests.is_empty());
assert!(monitor.inner.lock().unwrap().onchain_tx_handler.claimable_outpoints.is_empty());
}
// Create some initial channel
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1);
- let outpoint = OutPoint { txid: chan_1.3.txid(), index: 0 };
+ let outpoint = OutPoint { txid: chan_1.3.compute_txid(), index: 0 };
// Rebalance the network to generate htlc in the two directions
send_payment(&nodes[0], &vec!(&nodes[1])[..], 10_000_000);
// Create some initial channel
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1);
- let outpoint = OutPoint { txid: chan_1.3.txid(), index: 0 };
+ let outpoint = OutPoint { txid: chan_1.3.compute_txid(), index: 0 };
// Rebalance the network to generate htlc in the two directions
send_payment(&nodes[0], &vec!(&nodes[1])[..], 10_000_000);
} else {
if nodes[1].connect_style.borrow().updates_best_block_first() {
assert_eq!(bob_txn.len(), 3);
- assert_eq!(bob_txn[0].txid(), bob_txn[1].txid());
+ assert_eq!(bob_txn[0].compute_txid(), bob_txn[1].compute_txid());
} else {
assert_eq!(bob_txn.len(), 2);
}
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
let (_, _, _, real_channel_id, funding_tx) = create_chan_between_nodes(&nodes[0], &nodes[1]);
- let real_chan_funding_txo = chain::transaction::OutPoint { txid: funding_tx.txid(), index: 0 };
+ let real_chan_funding_txo = chain::transaction::OutPoint { txid: funding_tx.compute_txid(), index: 0 };
assert_eq!(ChannelId::v1_from_funding_outpoint(real_chan_funding_txo), real_channel_id);
nodes[2].node.create_channel(nodes[1].node.get_our_node_id(), 100_000, 0, 42, None, None).unwrap();
version: Version::TWO, lock_time: LockTime::ZERO,
input: tx.output.iter().enumerate().map(|(idx, _)| TxIn {
previous_output: BitcoinOutPoint {
- txid: tx.txid(),
+ txid: tx.compute_txid(),
vout: idx as u32,
},
script_sig: ScriptBuf::new(),
// We should broadcast an HTLC transaction spending our funding transaction first
let spending_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
assert_eq!(spending_txn.len(), 2);
- let htlc_tx = if spending_txn[0].txid() == node_txn[0].txid() {
+ let htlc_tx = if spending_txn[0].compute_txid() == node_txn[0].compute_txid() {
&spending_txn[1]
} else {
&spending_txn[0]
// Complete the persistence of the monitor.
nodes[0].chain_monitor.complete_sole_pending_chan_update(
- &ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.txid(), index: 1 })
+ &ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.compute_txid(), index: 1 })
);
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(nodes[0].tx_broadcaster.txn_broadcast().len(), 0);
// Force-close the channel for which we've completed the initial monitor.
- let funding_txo_1 = OutPoint { txid: tx.txid(), index: 0 };
- let funding_txo_2 = OutPoint { txid: tx.txid(), index: 1 };
+ let funding_txo_1 = OutPoint { txid: tx.compute_txid(), index: 0 };
+ let funding_txo_2 = OutPoint { txid: tx.compute_txid(), index: 1 };
let channel_id_1 = ChannelId::v1_from_funding_outpoint(funding_txo_1);
let channel_id_2 = ChannelId::v1_from_funding_outpoint(funding_txo_2);
let error_message = "Channel force-closed";
{
let broadcasted_txs = nodes[0].tx_broadcaster.txn_broadcast();
assert_eq!(broadcasted_txs.len(), 1);
- assert!(broadcasted_txs[0].txid() != tx.txid());
+ assert!(broadcasted_txs[0].compute_txid() != tx.compute_txid());
assert_eq!(broadcasted_txs[0].input.len(), 1);
- assert_eq!(broadcasted_txs[0].input[0].previous_output.txid, tx.txid());
+ assert_eq!(broadcasted_txs[0].input[0].previous_output.txid, tx.compute_txid());
}
// All channels in the batch should close immediately.
assert_eq!(nodes[0].tx_broadcaster.txn_broadcast().len(), 0);
// Force-close the channel for which we've completed the initial monitor.
- let funding_txo_1 = OutPoint { txid: tx.txid(), index: 0 };
- let funding_txo_2 = OutPoint { txid: tx.txid(), index: 1 };
+ let funding_txo_1 = OutPoint { txid: tx.compute_txid(), index: 0 };
+ let funding_txo_2 = OutPoint { txid: tx.compute_txid(), index: 1 };
let channel_id_1 = ChannelId::v1_from_funding_outpoint(funding_txo_1);
let channel_id_2 = ChannelId::v1_from_funding_outpoint(funding_txo_2);
let error_message = "Channel force-closed";
{
let broadcasted_txs = nodes[0].tx_broadcaster.txn_broadcast();
assert_eq!(broadcasted_txs.len(), 1);
- assert!(broadcasted_txs[0].txid() != tx.txid());
+ assert!(broadcasted_txs[0].compute_txid() != tx.compute_txid());
assert_eq!(broadcasted_txs[0].input.len(), 1);
- assert_eq!(broadcasted_txs[0].input[0].previous_output.txid, tx.txid());
+ assert_eq!(broadcasted_txs[0].input[0].previous_output.txid, tx.compute_txid());
}
// All channels in the batch should close immediately.
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let funding_tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 1_000_000, 0);
- let chan_id = ChannelId::v1_from_funding_outpoint(chain::transaction::OutPoint { txid: funding_tx.txid(), index: 0 });
+ let chan_id = ChannelId::v1_from_funding_outpoint(chain::transaction::OutPoint { txid: funding_tx.compute_txid(), index: 0 });
assert_eq!(nodes[0].node.list_channels().len(), 1);
assert_eq!(nodes[1].node.list_channels().len(), 1);
}
let transaction = msg.prevtx.as_transaction();
- let txid = transaction.txid();
+ let txid = transaction.compute_txid();
if let Some(tx_out) = transaction.output.get(msg.prevtx_out as usize) {
if !tx_out.script_pubkey.is_witness_program() {
return Err(AbortReason::ReceivedTooManyTxAddOutputs);
}
- if msg.sats < msg.script.dust_value().to_sat() {
+ if msg.sats < msg.script.minimal_non_dust().to_sat() {
// The receiving node:
// - MUST fail the negotiation if:
// - the sats amount is less than the dust_limit
fn sent_tx_add_input(&mut self, msg: &msgs::TxAddInput) -> Result<(), AbortReason> {
let tx = msg.prevtx.as_transaction();
let txin = TxIn {
- previous_output: OutPoint { txid: tx.txid(), vout: msg.prevtx_out },
+ previous_output: OutPoint { txid: tx.compute_txid(), vout: msg.prevtx_out },
sequence: Sequence(msg.sequence),
..Default::default()
};
fn generate_inputs(outputs: &[TestOutput]) -> Vec<(TxIn, TransactionU16LenLimited)> {
let tx = generate_tx(outputs);
- let txid = tx.txid();
+ let txid = tx.compute_txid();
tx.output
.iter()
.enumerate()
&vec![TestOutput::P2WPKH(1_000_000); tx_output_count as usize],
(1337 + remaining).into(),
);
- let txid = tx.txid();
+ let txid = tx.compute_txid();
let mut temp: Vec<(TxIn, TransactionU16LenLimited)> = tx
.output
let tx =
TransactionU16LenLimited::new(generate_tx(&[TestOutput::P2WPKH(1_000_000)])).unwrap();
let invalid_sequence_input = TxIn {
- previous_output: OutPoint { txid: tx.as_transaction().txid(), vout: 0 },
+ previous_output: OutPoint { txid: tx.as_transaction().compute_txid(), vout: 0 },
..Default::default()
};
do_test_interactive_tx_constructor(TestSession {
b_expected_remote_shared_output: Some((generate_p2wpkh_script_pubkey(), 0)),
});
let duplicate_input = TxIn {
- previous_output: OutPoint { txid: tx.as_transaction().txid(), vout: 0 },
+ previous_output: OutPoint { txid: tx.as_transaction().compute_txid(), vout: 0 },
sequence: Sequence::ENABLE_RBF_NO_LOCKTIME,
..Default::default()
};
});
// Non-initiator uses same prevout as initiator.
let duplicate_input = TxIn {
- previous_output: OutPoint { txid: tx.as_transaction().txid(), vout: 0 },
+ previous_output: OutPoint { txid: tx.as_transaction().compute_txid(), vout: 0 },
sequence: Sequence::ENABLE_RBF_NO_LOCKTIME,
..Default::default()
};
b_expected_remote_shared_output: Some((generate_funding_script_pubkey(), 95_000)),
});
let duplicate_input = TxIn {
- previous_output: OutPoint { txid: tx.as_transaction().txid(), vout: 0 },
+ previous_output: OutPoint { txid: tx.as_transaction().compute_txid(), vout: 0 },
sequence: Sequence::ENABLE_RBF_NO_LOCKTIME,
..Default::default()
};
description: "Initiator sends an output below dust value",
inputs_a: vec![],
outputs_a: generate_funding_output(
- generate_p2wsh_script_pubkey().dust_value().to_sat() - 1,
+ generate_p2wsh_script_pubkey().minimal_non_dust().to_sat() - 1,
),
inputs_b: vec![],
outputs_b: vec![],
// Remove the corresponding outputs and transactions the chain source is
// watching. This is to make sure the `Drop` function assertions pass.
nodes.get_mut(0).unwrap().chain_source.remove_watched_txn_and_outputs(
- OutPoint { txid: funding_tx.txid(), index: 0 },
+ OutPoint { txid: funding_tx.compute_txid(), index: 0 },
funding_tx.output[0].script_pubkey.clone()
);
}
let (_, _, chan_id, funding_tx) =
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 1_000_000);
- let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
assert_eq!(ChannelId::v1_from_funding_outpoint(funding_outpoint), chan_id);
let chan_feerate = get_feerate!(nodes[0], nodes[1], chan_id) as u64;
],
};
if anchors {
- nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 }, coinbase_tx.output[0].value);
- nodes[1].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 1 }, coinbase_tx.output[1].value);
+ nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 }, coinbase_tx.output[0].value);
+ nodes[1].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 1 }, coinbase_tx.output[1].value);
}
let (_, _, chan_id, funding_tx) =
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 1_000_000);
- let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
assert_eq!(ChannelId::v1_from_funding_outpoint(funding_outpoint), chan_id);
// This HTLC is immediately claimed, giving node B the preimage
],
};
if anchors {
- nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 }, coinbase_tx.output[0].value);
- nodes[1].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 1 }, coinbase_tx.output[1].value);
+ nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 }, coinbase_tx.output[0].value);
+ nodes[1].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 1 }, coinbase_tx.output[1].value);
}
// Create a single channel with two pending HTLCs from nodes[0] to nodes[1], one which nodes[1]
// knows the preimage for, one which it does not.
let (_, _, chan_id, funding_tx) = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
- let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
let (route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], 10_000_000);
let htlc_cltv_timeout = nodes[0].best_block_info().1 + TEST_FINAL_CLTV + 1; // Note ChannelManager adds one to CLTV timeouts for safety
if nodes[0].connect_style.borrow().updates_best_block_first() {
let mut txn = nodes[0].tx_broadcaster.txn_broadcast();
assert_eq!(txn.len(), 1);
- assert_eq!(txn[0].txid(), commitment_tx.txid());
+ assert_eq!(txn[0].compute_txid(), commitment_tx.compute_txid());
}
let htlc_balance_known_preimage = Balance::MaybeTimeoutClaimableHTLC {
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let (_, _, chan_id, funding_tx) = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000);
- let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
// Send two HTLCs, one from A to B, and one from B to A.
let to_b_failed_payment_hash = route_payment(&nodes[0], &[&nodes[1]], 10_000_000).1;
let (_, _, chan_id, funding_tx) =
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 100_000_000);
- let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
assert_eq!(ChannelId::v1_from_funding_outpoint(funding_outpoint), chan_id);
// We create five HTLCs for B to claim against A's revoked commitment transaction:
sorted_vec(nodes[1].chain_monitor.chain_monitor.get_monitor(funding_outpoint).unwrap().get_claimable_balances()));
mine_transaction(&nodes[1], &as_revoked_txn[0]);
- let mut claim_txn: Vec<_> = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().drain(..).filter(|tx| tx.input.iter().any(|inp| inp.previous_output.txid == as_revoked_txn[0].txid())).collect();
+ let mut claim_txn: Vec<_> = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().drain(..).filter(|tx| tx.input.iter().any(|inp| inp.previous_output.txid == as_revoked_txn[0].compute_txid())).collect();
// Currently the revoked commitment is claimed in four transactions as the HTLCs all expire
// quite soon.
assert_eq!(claim_txn.len(), 4);
],
};
if anchors {
- nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 }, coinbase_tx.output[0].value);
- nodes[1].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 1 }, coinbase_tx.output[1].value);
+ nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 }, coinbase_tx.output[0].value);
+ nodes[1].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 1 }, coinbase_tx.output[1].value);
}
// Create some initial channels
let (_, _, chan_id, funding_tx) =
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 12_000_000);
- let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
assert_eq!(ChannelId::v1_from_funding_outpoint(funding_outpoint), chan_id);
let payment_preimage = route_payment(&nodes[0], &[&nodes[1]], 3_000_100).0;
let failed_payment_hash = route_payment(&nodes[1], &[&nodes[0]], 1_000_000).1;
let revoked_local_txn = get_local_commitment_txn!(nodes[1], chan_id);
assert_eq!(revoked_local_txn[0].input.len(), 1);
- assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, funding_tx.txid());
+ assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, funding_tx.compute_txid());
if anchors {
assert_eq!(revoked_local_txn[0].output[4].value.to_sat(), 11000); // to_self output
} else {
script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
}],
};
- nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 }, coinbase_tx.output[0].value);
+ nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 }, coinbase_tx.output[0].value);
let (_, _, chan_id, funding_tx) =
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 100_000_000);
- let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
assert_eq!(ChannelId::v1_from_funding_outpoint(funding_outpoint), chan_id);
// We create two HTLCs, one which we will give A the preimage to to generate an HTLC-Success
],
};
if anchors {
- nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 }, coinbase_tx.output[0].value);
- nodes[1].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 1 }, coinbase_tx.output[1].value);
+ nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 }, coinbase_tx.output[0].value);
+ nodes[1].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 1 }, coinbase_tx.output[1].value);
}
// Create a channel from A -> B
let (_, _, chan_ab_id, funding_tx_ab) =
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000 /* channel_value (sat) */, 0 /* push_msat */);
- let funding_outpoint_ab = OutPoint { txid: funding_tx_ab.txid(), index: 0 };
+ let funding_outpoint_ab = OutPoint { txid: funding_tx_ab.compute_txid(), index: 0 };
assert_eq!(ChannelId::v1_from_funding_outpoint(funding_outpoint_ab), chan_ab_id);
// Create a channel from B -> C
let (_, _, chan_bc_id, funding_tx_bc) =
create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000 /* channel_value (sat) */, 0 /* push_msat */);
- let funding_outpoint_bc = OutPoint { txid: funding_tx_bc.txid(), index: 0 };
+ let funding_outpoint_bc = OutPoint { txid: funding_tx_bc.compute_txid(), index: 0 };
assert_eq!(ChannelId::v1_from_funding_outpoint(funding_outpoint_bc), chan_bc_id);
let (chan_feerate, channel_type_features) = if outbound_payment {
if nodes[0].connect_style.borrow().updates_best_block_first() {
let txn = nodes[0].tx_broadcaster.txn_broadcast();
assert_eq!(txn.len(), 1);
- assert_eq!(txn[0].txid(), commitment_tx.txid());
+ assert_eq!(txn[0].compute_txid(), commitment_tx.compute_txid());
}
// Connect blocks until the HTLC's expiration is met, expecting a transaction broadcast.
script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
}],
};
- nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 }, coinbase_tx.output[0].value);
+ nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 }, coinbase_tx.output[0].value);
// Set up a helper closure we'll use throughout our test. We should only expect retries without
// bumps if fees have not increased after a block has been connected (assuming the height timer
// If we have a `ConnectStyle` that advertises the new block first without the transactions,
// we'll receive an extra bumped claim.
if nodes[0].connect_style.borrow().updates_best_block_first() {
- nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 }, coinbase_tx.output[0].value);
- nodes[0].wallet_source.remove_utxo(bitcoin::OutPoint { txid: htlc_tx.txid(), vout: 1 });
+ nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 }, coinbase_tx.output[0].value);
+ nodes[0].wallet_source.remove_utxo(bitcoin::OutPoint { txid: htlc_tx.compute_txid(), vout: 1 });
check_htlc_retry(true, anchors);
}
nodes[0].chain_monitor.chain_monitor.rebroadcast_pending_claims();
script_pubkey: nodes[0].wallet_source.get_change_script().unwrap(),
}],
};
- nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 }, coinbase_tx.output[0].value);
+ nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 }, coinbase_tx.output[0].value);
nodes[0].bump_tx_handler.handle_event(&event);
let mut txn = nodes[0].tx_broadcaster.unique_txn_broadcast();
assert_eq!(txn.len(), 2);
script_pubkey: nodes[1].wallet_source.get_change_script().unwrap(),
}],
};
- nodes[1].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 }, utxo_value);
+ nodes[1].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 }, utxo_value);
match event {
Event::BumpTransaction(event) => nodes[1].bump_tx_handler.handle_event(&event),
_ => panic!("Unexpected event"),
let txn = nodes[1].tx_broadcaster.txn_broadcast();
assert_eq!(txn.len(), 2);
assert_eq!(txn[0].output.len(), 6); // 2 HTLC outputs + 1 to_self output + 1 to_remote output + 2 anchor outputs
- if txn[0].input[0].previous_output.txid == chan_a.3.txid() {
+ if txn[0].input[0].previous_output.txid == chan_a.3.compute_txid() {
check_spends!(&txn[0], &chan_a.3);
} else {
check_spends!(&txn[0], &chan_b.3);
let txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
assert_eq!(txn.len(), 4);
- let (revoked_htlc_claim_a, revoked_htlc_claim_b) = if txn[0].input[0].previous_output.txid == revoked_commitment_txs[0].txid() {
+ let (revoked_htlc_claim_a, revoked_htlc_claim_b) = if txn[0].input[0].previous_output.txid == revoked_commitment_txs[0].compute_txid() {
(if txn[0].input.len() == 2 { &txn[0] } else { &txn[1] }, if txn[2].input.len() == 2 { &txn[2] } else { &txn[3] })
} else {
(if txn[2].input.len() == 2 { &txn[2] } else { &txn[3] }, if txn[0].input.len() == 2 { &txn[0] } else { &txn[1] })
version: Version::TWO,
lock_time: LockTime::ZERO,
input: vec![TxIn { // Fee input
- previous_output: bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 },
+ previous_output: bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 },
..Default::default()
}],
output: vec![TxOut { // Fee input change
let revoked_htlc_claims = txn.iter().filter(|tx|
tx.input.len() == 2 &&
tx.output.len() == 1 &&
- tx.input[0].previous_output.txid == htlc_tx.txid()
+ tx.input[0].previous_output.txid == htlc_tx.compute_txid()
).collect::<Vec<_>>();
assert_eq!(revoked_htlc_claims.len(), 2);
for revoked_htlc_claim in revoked_htlc_claims {
let mut revoked_claim_transaction_map = new_hash_map();
for current_tx in txn.into_iter() {
- revoked_claim_transaction_map.insert(current_tx.txid(), current_tx);
+ revoked_claim_transaction_map.insert(current_tx.compute_txid(), current_tx);
}
revoked_claim_transaction_map
};
],
};
if anchors {
- nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.txid(), vout: 0 }, coinbase_tx.output[0].value);
+ nodes[0].wallet_source.add_utxo(bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 }, coinbase_tx.output[0].value);
}
// Open a channel and route a payment. We'll let it timeout to claim it.
{
let mut txn = nodes[0].tx_broadcaster.txn_broadcast();
assert_eq!(txn.len(), 1);
- assert_eq!(txn[0].txid(), htlc_timeout_tx.txid());
- assert_ne!(txn[0].wtxid(), htlc_timeout_tx.wtxid());
+ assert_eq!(txn[0].compute_txid(), htlc_timeout_tx.compute_txid());
+ assert_ne!(txn[0].compute_wtxid(), htlc_timeout_tx.compute_wtxid());
}
}
if !confirm_before_reload {
let as_broadcasted_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0);
assert_eq!(as_broadcasted_txn.len(), 1);
- assert_eq!(as_broadcasted_txn[0].txid(), as_commitment_tx.txid());
+ assert_eq!(as_broadcasted_txn[0].compute_txid(), as_commitment_tx.compute_txid());
} else {
assert!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().is_empty());
}
mine_transaction(&nodes[0], &as_commitment_tx);
let txn = nodes[0].tx_broadcaster.unique_txn_broadcast();
assert_eq!(txn.len(), 1);
- assert_eq!(txn[0].txid(), as_commitment_tx.txid());
+ assert_eq!(txn[0].compute_txid(), as_commitment_tx.compute_txid());
}
mine_transaction(&nodes[0], &bs_htlc_claim_txn);
expect_payment_sent(&nodes[0], payment_preimage_1, None, true, false);
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id());
let chan_0_monitor_serialized =
- get_monitor!(nodes[0], ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.txid(), index: 0 })).encode();
+ get_monitor!(nodes[0], ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.compute_txid(), index: 0 })).encode();
reload_node!(nodes[0], nodes[0].node.encode(), &[&chan_0_monitor_serialized], persister, new_chain_monitor, nodes_0_deserialized);
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init {
let events_4 = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events_4.len(), 0);
assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().len(), 1);
- assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap()[0].txid(), funding_output.txid);
+ assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap()[0].compute_txid(), funding_output.txid);
// Make sure the channel is functioning as though the de/serialization never happened
assert_eq!(nodes[0].node.list_channels().len(), 1);
let txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap();
assert_eq!(txn.len(), 1);
check_spends!(txn[0], funding_tx);
- assert_eq!(txn[0].input[0].previous_output.txid, funding_tx.txid());
+ assert_eq!(txn[0].input[0].previous_output.txid, funding_tx.compute_txid());
}
check_added_monitors!(nodes[0], 1);
assert_eq!(nodes[0].tx_broadcaster.txn_broadcast().len(), 0);
// Reload the node while a subset of the channels in the funding batch have persisted monitors.
- let channel_id_1 = ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.txid(), index: 0 });
+ let channel_id_1 = ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.compute_txid(), index: 0 });
let node_encoded = nodes[0].node.encode();
let channel_monitor_1_serialized = get_monitor!(nodes[0], channel_id_1).encode();
reload_node!(nodes[0], node_encoded, &[&channel_monitor_1_serialized], new_persister, new_chain_monitor, new_channel_manager);
{
let broadcasted_txs = nodes[0].tx_broadcaster.txn_broadcast();
assert_eq!(broadcasted_txs.len(), 1);
- assert!(broadcasted_txs[0].txid() != tx.txid());
+ assert!(broadcasted_txs[0].compute_txid() != tx.compute_txid());
assert_eq!(broadcasted_txs[0].input.len(), 1);
- assert_eq!(broadcasted_txs[0].input[0].previous_output.txid, tx.txid());
+ assert_eq!(broadcasted_txs[0].input[0].previous_output.txid, tx.compute_txid());
}
// Ensure the channels don't exist anymore.
assert_eq!(relevant_txids[0].1, chan_conf_height);
assert_eq!(block_hash_opt, Some(expected_hash));
let txid = relevant_txids[0].0;
- assert_eq!(txid, chan.3.txid());
+ assert_eq!(txid, chan.3.compute_txid());
nodes[0].node.transaction_unconfirmed(&txid);
assert_eq!(nodes[0].node.list_usable_channels().len(), 0);
} else if connect_style == ConnectStyle::FullBlockViaListen {
assert_eq!(chan_conf_height, relevant_txids[0].1);
assert_eq!(block_hash_opt, Some(expected_hash));
let txid = relevant_txids[0].0;
- assert_eq!(txid, chan.3.txid());
+ assert_eq!(txid, chan.3.compute_txid());
nodes[0].node.transaction_unconfirmed(&txid);
assert_eq!(nodes[0].node.list_channels().len(), 0);
} else if connect_style == ConnectStyle::FullBlockViaListen {
assert_eq!(remote_txn.len(), 3);
assert_eq!(remote_txn[0].output.len(), 4);
assert_eq!(remote_txn[0].input.len(), 1);
- assert_eq!(remote_txn[0].input[0].previous_output.txid, chan.3.txid());
+ assert_eq!(remote_txn[0].input[0].previous_output.txid, chan.3.compute_txid());
check_spends!(remote_txn[1], remote_txn[0]);
check_spends!(remote_txn[2], remote_txn[0]);
let (_, _, chan_id, funding_tx) =
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 100_000_000);
- let funding_outpoint = OutPoint { txid: funding_tx.txid(), index: 0 };
+ let funding_outpoint = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
assert_eq!(ChannelId::v1_from_funding_outpoint(funding_outpoint), chan_id);
let remote_txn_a = get_local_commitment_txn!(nodes[0], chan_id);
let mut txn = nodes[0].tx_broadcaster.txn_broadcast();
assert_eq!(txn.len(), 1);
let current_commitment_a = txn.pop().unwrap();
- assert_ne!(current_commitment_a.txid(), prev_commitment_a.txid());
+ assert_ne!(current_commitment_a.compute_txid(), prev_commitment_a.compute_txid());
check_spends!(current_commitment_a, funding_tx);
mine_transaction(&nodes[0], ¤t_commitment_a);
assert_eq!(txn.len(), 2);
check_spends!(txn[0], txn[1]); // HTLC timeout A
check_spends!(txn[1], funding_tx); // Commitment A
- assert_ne!(txn[1].txid(), commitment_b.txid());
+ assert_ne!(txn[1].compute_txid(), commitment_b.compute_txid());
}
}
}
mine_transaction(&nodes[0], &tx);
mine_transaction(&nodes[1], &tx);
- nodes[0].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.txid(), index: 0 }), &nodes[1].node.get_our_node_id()).unwrap();
+ nodes[0].node.close_channel(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.compute_txid(), index: 0 }), &nodes[1].node.get_our_node_id()).unwrap();
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &node_0_shutdown);
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
let err = "Error in transaction funding: Misuse error: No output matched the script_pubkey and value in the FundingGenerationReady event".to_string();
let temp_err = "No output matched the script_pubkey and value in the FundingGenerationReady event".to_string();
- let post_funding_chan_id_a = ChannelId::v1_from_funding_txid(tx.txid().as_ref(), 0);
+ let post_funding_chan_id_a = ChannelId::v1_from_funding_txid(tx.compute_txid().as_ref(), 0);
let close = [
ExpectedCloseEvent::from_id_reason(post_funding_chan_id_a, true, ClosureReason::ProcessingError { err: err.clone() }),
ExpectedCloseEvent::from_id_reason(temp_chan_id_b, false, ClosureReason::ProcessingError { err: temp_err }),
let mut v = Vec::new();
d.read_to_end(&mut v).unwrap();
bench.bench_function("read_network_graph", |b| b.iter(||
- NetworkGraph::read(&mut std::io::Cursor::new(black_box(&v)), &logger).unwrap()
+ NetworkGraph::read(&mut crate::io::Cursor::new(black_box(&v)), &logger).unwrap()
));
}
pub fn write_network_graph(bench: &mut Criterion) {
let logger = crate::util::test_utils::TestLogger::new();
let (mut d, _) = crate::routing::router::bench_utils::get_graph_scorer_file().unwrap();
- let net_graph = NetworkGraph::read(&mut d, &logger).unwrap();
+ let mut graph_buffer = Vec::new();
+ d.read_to_end(&mut graph_buffer).unwrap();
+ let net_graph = NetworkGraph::read(&mut &graph_buffer[..], &logger).unwrap();
bench.bench_function("write_network_graph", |b| b.iter(||
black_box(&net_graph).encode()
));
debug_assert!(false, "We should never generate unknown transaction types");
write!(f, "unknown tx type ").unwrap();
}
- write!(f, "with txid {}", self.0.txid())?;
+ write!(f, "with txid {}", self.0.compute_txid())?;
Ok(())
}
}
impl<T: MaybeReadable> Readable for WithoutLength<Vec<T>> {
#[inline]
- fn read<R: Read>(mut reader: &mut R) -> Result<Self, DecodeError> {
+ fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError> {
let mut values = Vec::new();
loop {
let mut track_read = ReadTrackingReader::new(reader);
log_debug!(
self.logger,
"Generating and broadcasting sweeping transaction {}",
- spending_tx.txid()
+ spending_tx.compute_txid()
);
spending_tx
},
if cur_height >= confirmation_height + ANTI_REORG_DELAY - 1 {
log_debug!(self.logger,
"Pruning swept output as sufficiently confirmed via spend in transaction {:?}. Pruned descriptor: {:?}",
- o.status.latest_spending_tx().map(|t| t.txid()), o.descriptor
+ o.status.latest_spending_tx().map(|t| t.compute_txid()), o.descriptor
);
return false;
}
let unconf_height = state_lock
.outputs
.iter()
- .find(|o| o.status.latest_spending_tx().map(|tx| tx.txid()) == Some(*txid))
+ .find(|o| o.status.latest_spending_tx().map(|tx| tx.compute_txid()) == Some(*txid))
.and_then(|o| o.status.confirmation_height());
if let Some(unconf_height) = unconf_height {
confirmation_height,
confirmation_hash,
..
- } => Some((latest_spending_tx.txid(), confirmation_height, Some(confirmation_hash))),
+ } => Some((
+ latest_spending_tx.compute_txid(),
+ confirmation_height,
+ Some(confirmation_hash),
+ )),
_ => None,
})
.collect::<Vec<_>>()
use bitcoin::secp256k1::{SecretKey, PublicKey};
use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature};
#[cfg(taproot)]
-use musig2::types::{PartialSignature, PublicNonce, SecretNonce};
+use musig2::types::{PartialSignature, PublicNonce};
use crate::sign::HTLCDescriptor;
use crate::util::ser::{Writeable, Writer};
use crate::io::Error;
pub fn unique_txn_broadcast(&self) -> Vec<Transaction> {
let mut txn = self.txn_broadcasted.lock().unwrap().split_off(0);
let mut seen = new_hash_set();
- txn.retain(|tx| seen.insert(tx.txid()));
+ txn.retain(|tx| seen.insert(tx.compute_txid()));
txn
}
}
if output_value >= input_value { return Err(()); }
}
- let dust_value = change_destination_script.dust_value();
+ let dust_value = change_destination_script.minimal_non_dust();
let mut change_output = TxOut {
script_pubkey: change_destination_script,
value: Amount::ZERO,
fn test_tx_change_edge() {
// Check that we never add dust outputs
let mut tx = Transaction { version: Version::TWO, lock_time: LockTime::ZERO, input: Vec::new(), output: Vec::new() };
- let orig_wtxid = tx.wtxid();
+ let orig_wtxid = tx.compute_wtxid();
let output_spk = ScriptBuf::new_p2pkh(&PubkeyHash::hash(&[0; 0]));
- assert_eq!(output_spk.dust_value().to_sat(), 546);
+ assert_eq!(output_spk.minimal_non_dust().to_sat(), 546);
// base size = version size + varint[input count] + input size + varint[output count] + output size + lock time size
// total size = version size + marker + flag + varint[input count] + input size + varint[output count] + output size + lock time size
// weight = 3 * base size + total size = 3 * (4 + 1 + 0 + 1 + 0 + 4) + (4 + 1 + 1 + 1 + 0 + 1 + 0 + 4) = 3 * 10 + 12 = 42
assert_eq!(tx.weight().to_wu(), 42);
// 10 sats isn't enough to pay fee on a dummy transaction...
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(10), 0, 250, output_spk.clone()).is_err());
- assert_eq!(tx.wtxid(), orig_wtxid); // Failure doesn't change the transaction
+ assert_eq!(tx.compute_wtxid(), orig_wtxid); // Failure doesn't change the transaction
// but 11 (= ceil(42 * 250 / 1000)) is, just not enough to add a change output...
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(11), 0, 250, output_spk.clone()).is_ok());
assert_eq!(tx.output.len(), 0);
- assert_eq!(tx.wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
+ assert_eq!(tx.compute_wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(549), 0, 250, output_spk.clone()).is_ok());
assert_eq!(tx.output.len(), 0);
- assert_eq!(tx.wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
+ assert_eq!(tx.compute_wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
// 590 is also not enough
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(590), 0, 250, output_spk.clone()).is_ok());
assert_eq!(tx.output.len(), 0);
- assert_eq!(tx.wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
+ assert_eq!(tx.compute_wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
// at 591 we can afford the change output at the dust limit (546)
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(591), 0, 250, output_spk.clone()).is_ok());
assert_eq!(tx.output.len(), 1);
assert_eq!(tx.weight().to_wu() / 4, 590-546); // New weight is exactly the fee we wanted.
tx.output.pop();
- assert_eq!(tx.wtxid(), orig_wtxid); // The only change is the addition of one output.
+ assert_eq!(tx.compute_wtxid(), orig_wtxid); // The only change is the addition of one output.
}
#[test]
}], output: vec![TxOut {
script_pubkey: Builder::new().push_int(1).into_script(), value: Amount::from_sat(1000)
}] };
- let orig_wtxid = tx.wtxid();
+ let orig_wtxid = tx.compute_wtxid();
let orig_weight = tx.weight().to_wu();
assert_eq!(orig_weight / 4, 61);
- assert_eq!(Builder::new().push_int(2).into_script().dust_value().to_sat(), 474);
+ assert_eq!(Builder::new().push_int(2).into_script().minimal_non_dust().to_sat(), 474);
// Input value of the output value + fee - 1 should fail:
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(1000 + 61 + 100 - 1), 400, 250, Builder::new().push_int(2).into_script()).is_err());
- assert_eq!(tx.wtxid(), orig_wtxid); // Failure doesn't change the transaction
+ assert_eq!(tx.compute_wtxid(), orig_wtxid); // Failure doesn't change the transaction
// but one more input sat should succeed, without changing the transaction
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(1000 + 61 + 100), 400, 250, Builder::new().push_int(2).into_script()).is_ok());
- assert_eq!(tx.wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
+ assert_eq!(tx.compute_wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
// In order to get a change output, we need to add 474 plus the output's weight / 4 (10)...
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(1000 + 61 + 100 + 474 + 9), 400, 250, Builder::new().push_int(2).into_script()).is_ok());
- assert_eq!(tx.wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
+ assert_eq!(tx.compute_wtxid(), orig_wtxid); // If we don't add an output, we don't change the transaction
assert!(maybe_add_change_output(&mut tx, Amount::from_sat(1000 + 61 + 100 + 474 + 10), 400, 250, Builder::new().push_int(2).into_script()).is_ok());
assert_eq!(tx.output.len(), 2);
assert_eq!(tx.output[1].script_pubkey, Builder::new().push_int(2).into_script());
assert_eq!(tx.weight().to_wu() - orig_weight, 40); // Weight difference matches what we had to add above
tx.output.pop();
- assert_eq!(tx.wtxid(), orig_wtxid); // The only change is the addition of one output.
+ assert_eq!(tx.compute_wtxid(), orig_wtxid); // The only change is the addition of one output.
}
}