Skip to content

Commit 85f1a91

Browse files
authored
Merge pull request #914 from TheBlueMatt/2021-05-log-txids
Always log_info when we broadcast a transaction, including the txid
2 parents c9b12e1 + 71d640a commit 85f1a91

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
15681568
L::Target: Logger,
15691569
{
15701570
for tx in self.get_latest_holder_commitment_txn(logger).iter() {
1571+
log_info!(logger, "Broadcasting local {}", log_tx!(tx));
15711572
broadcaster.broadcast_transaction(tx);
15721573
}
15731574
self.pending_monitor_events.push(MonitorEvent::CommitmentTxBroadcasted(self.funding_info.0));

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2540,6 +2540,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
25402540
},
25412541
}
25422542
if let Some(tx) = funding_broadcastable {
2543+
log_info!(self.logger, "Broadcasting funding transaction with txid {}", tx.txid());
25432544
self.tx_broadcaster.broadcast_transaction(&tx);
25442545
}
25452546
if let Some(msg) = funding_locked {
@@ -2695,6 +2696,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
26952696
hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close("Failed to find corresponding channel".to_owned(), msg.channel_id))
26962697
}
26972698
};
2699+
log_info!(self.logger, "Broadcasting funding transaction with txid {}", funding_tx.txid());
26982700
self.tx_broadcaster.broadcast_transaction(&funding_tx);
26992701
Ok(())
27002702
}
@@ -2809,7 +2811,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
28092811
}
28102812
};
28112813
if let Some(broadcast_tx) = tx {
2812-
log_trace!(self.logger, "Broadcast onchain {}", log_tx!(broadcast_tx));
2814+
log_info!(self.logger, "Broadcasting {}", log_tx!(broadcast_tx));
28132815
self.tx_broadcaster.broadcast_transaction(&broadcast_tx);
28142816
}
28152817
if let Some(chan) = chan_option {

lightning/src/ln/onchaintx.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
742742
self.claimable_outpoints.insert(k.clone(), (txid, height));
743743
}
744744
self.pending_claim_requests.insert(txid, claim_material);
745-
log_trace!(logger, "Broadcast onchain {}", log_tx!(tx));
745+
log_info!(logger, "Broadcasting onchain {}", log_tx!(tx));
746746
broadcaster.broadcast_transaction(&tx);
747747
}
748748
}
@@ -859,7 +859,7 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
859859
log_trace!(logger, "Bumping {} candidates", bump_candidates.len());
860860
for (first_claim_txid, claim_material) in bump_candidates.iter() {
861861
if let Some((new_timer, new_feerate, bump_tx)) = self.generate_claim_tx(height, &claim_material, &*fee_estimator, &*logger) {
862-
log_trace!(logger, "Broadcast onchain {}", log_tx!(bump_tx));
862+
log_info!(logger, "Broadcasting onchain {}", log_tx!(bump_tx));
863863
broadcaster.broadcast_transaction(&bump_tx);
864864
if let Some(claim_material) = self.pending_claim_requests.get_mut(first_claim_txid) {
865865
claim_material.height_timer = new_timer;
@@ -926,6 +926,7 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
926926
if let Some((new_timer, new_feerate, bump_tx)) = self.generate_claim_tx(height, &claim_material, &&*fee_estimator, &&*logger) {
927927
claim_material.height_timer = new_timer;
928928
claim_material.feerate_previous = new_feerate;
929+
log_info!(logger, "Broadcasting onchain {}", log_tx!(bump_tx));
929930
broadcaster.broadcast_transaction(&bump_tx);
930931
}
931932
}

lightning/src/util/macro_logger.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,29 @@ impl<'a> std::fmt::Display for DebugTx<'a> {
100100
if self.0.input.len() >= 1 && self.0.input.iter().any(|i| !i.witness.is_empty()) {
101101
if self.0.input.len() == 1 && self.0.input[0].witness.last().unwrap().len() == 71 &&
102102
(self.0.input[0].sequence >> 8*3) as u8 == 0x80 {
103-
write!(f, "commitment tx")?;
103+
write!(f, "commitment tx ")?;
104104
} else if self.0.input.len() == 1 && self.0.input[0].witness.last().unwrap().len() == 71 {
105-
write!(f, "closing tx")?;
105+
write!(f, "closing tx ")?;
106106
} else if self.0.input.len() == 1 && HTLCType::scriptlen_to_htlctype(self.0.input[0].witness.last().unwrap().len()) == Some(HTLCType::OfferedHTLC) &&
107107
self.0.input[0].witness.len() == 5 {
108-
write!(f, "HTLC-timeout tx")?;
108+
write!(f, "HTLC-timeout tx ")?;
109109
} else if self.0.input.len() == 1 && HTLCType::scriptlen_to_htlctype(self.0.input[0].witness.last().unwrap().len()) == Some(HTLCType::AcceptedHTLC) &&
110110
self.0.input[0].witness.len() == 5 {
111-
write!(f, "HTLC-success tx")?;
111+
write!(f, "HTLC-success tx ")?;
112112
} else {
113113
for inp in &self.0.input {
114114
if !inp.witness.is_empty() {
115115
if HTLCType::scriptlen_to_htlctype(inp.witness.last().unwrap().len()) == Some(HTLCType::OfferedHTLC) { write!(f, "preimage-")?; break }
116116
else if HTLCType::scriptlen_to_htlctype(inp.witness.last().unwrap().len()) == Some(HTLCType::AcceptedHTLC) { write!(f, "timeout-")?; break }
117117
}
118118
}
119-
write!(f, "tx")?;
119+
write!(f, "tx ")?;
120120
}
121121
} else {
122-
write!(f, "INVALID TRANSACTION")?;
122+
debug_assert!(false, "We should never generate unknown transaction types");
123+
write!(f, "unknown tx type ").unwrap();
123124
}
125+
write!(f, "with txid {}", self.0.txid())?;
124126
Ok(())
125127
}
126128
}

0 commit comments

Comments
 (0)