mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-24 23:08:36 +01:00
Add log for every tx broadcast
Added macro log_tx in macro_logger.rs
This commit is contained in:
parent
126b514168
commit
9df0250dbb
3 changed files with 30 additions and 0 deletions
|
@ -768,6 +768,7 @@ impl ChannelManager {
|
||||||
self.fail_htlc_backwards_internal(self.channel_state.lock().unwrap(), htlc_source.0, &htlc_source.1, HTLCFailReason::Reason { failure_code: 0x4000 | 8, data: Vec::new() });
|
self.fail_htlc_backwards_internal(self.channel_state.lock().unwrap(), htlc_source.0, &htlc_source.1, HTLCFailReason::Reason { failure_code: 0x4000 | 8, data: Vec::new() });
|
||||||
}
|
}
|
||||||
for tx in local_txn {
|
for tx in local_txn {
|
||||||
|
log_trace!(self, "Broadcast onchain {}", log_tx!(tx));
|
||||||
self.tx_broadcaster.broadcast_transaction(&tx);
|
self.tx_broadcaster.broadcast_transaction(&tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2064,6 +2065,7 @@ impl ChannelManager {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if let Some(broadcast_tx) = tx {
|
if let Some(broadcast_tx) = tx {
|
||||||
|
log_trace!(self, "Broadcast onchain {}", log_tx!(broadcast_tx));
|
||||||
self.tx_broadcaster.broadcast_transaction(&broadcast_tx);
|
self.tx_broadcaster.broadcast_transaction(&broadcast_tx);
|
||||||
}
|
}
|
||||||
if let Some(chan) = chan_option {
|
if let Some(chan) = chan_option {
|
||||||
|
|
|
@ -2170,6 +2170,7 @@ impl ChannelMonitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for tx in txn.iter() {
|
for tx in txn.iter() {
|
||||||
|
log_trace!(self, "Broadcast onchain {}", log_tx!(tx));
|
||||||
broadcaster.broadcast_transaction(tx);
|
broadcaster.broadcast_transaction(tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2205,6 +2206,7 @@ impl ChannelMonitor {
|
||||||
let mut pending_claims = Vec::new();
|
let mut pending_claims = Vec::new();
|
||||||
if let Some(ref cur_local_tx) = self.current_local_signed_commitment_tx {
|
if let Some(ref cur_local_tx) = self.current_local_signed_commitment_tx {
|
||||||
if self.would_broadcast_at_height(height) {
|
if self.would_broadcast_at_height(height) {
|
||||||
|
log_trace!(self, "Broadcast onchain {}", log_tx!(cur_local_tx.tx));
|
||||||
broadcaster.broadcast_transaction(&cur_local_tx.tx);
|
broadcaster.broadcast_transaction(&cur_local_tx.tx);
|
||||||
match self.key_storage {
|
match self.key_storage {
|
||||||
Storage::Local { ref delayed_payment_base_key, ref latest_per_commitment_point, .. } => {
|
Storage::Local { ref delayed_payment_base_key, ref latest_per_commitment_point, .. } => {
|
||||||
|
@ -2215,6 +2217,7 @@ impl ChannelMonitor {
|
||||||
watch_outputs.push((cur_local_tx.txid.clone(), new_outputs));
|
watch_outputs.push((cur_local_tx.txid.clone(), new_outputs));
|
||||||
}
|
}
|
||||||
for tx in txs {
|
for tx in txs {
|
||||||
|
log_trace!(self, "Broadcast onchain {}", log_tx!(tx));
|
||||||
broadcaster.broadcast_transaction(&tx);
|
broadcaster.broadcast_transaction(&tx);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2226,6 +2229,7 @@ impl ChannelMonitor {
|
||||||
watch_outputs.push((cur_local_tx.txid.clone(), new_outputs));
|
watch_outputs.push((cur_local_tx.txid.clone(), new_outputs));
|
||||||
}
|
}
|
||||||
for tx in txs {
|
for tx in txs {
|
||||||
|
log_trace!(self, "Broadcast onchain {}", log_tx!(tx));
|
||||||
broadcaster.broadcast_transaction(&tx);
|
broadcaster.broadcast_transaction(&tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use chain::transaction::OutPoint;
|
use chain::transaction::OutPoint;
|
||||||
|
|
||||||
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
|
use bitcoin_hashes::sha256d::Hash as Sha256dHash;
|
||||||
|
use bitcoin::blockdata::transaction::Transaction;
|
||||||
use secp256k1::key::PublicKey;
|
use secp256k1::key::PublicKey;
|
||||||
|
|
||||||
use ln::router::Route;
|
use ln::router::Route;
|
||||||
|
@ -89,6 +90,29 @@ macro_rules! log_route {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) struct DebugTx<'a>(pub &'a Transaction);
|
||||||
|
impl<'a> std::fmt::Display for DebugTx<'a> {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||||
|
if self.0.input.len() == 1 && self.0.input[0].witness.last().unwrap().len() == 71 && (self.0.input[0].sequence >> 8*3) as u8 == 0x80 { write!(f, "commitment tx")?; }
|
||||||
|
else if self.0.input.len() == 1 && self.0.input[0].witness.last().unwrap().len() == 71 { write!(f, "closing tx")?; }
|
||||||
|
else if self.0.input.len() == 1 && self.0.input[0].witness.last().unwrap().len() == 133 && self.0.input[0].witness.len() == 5 { write!(f, "HTLC-timeout tx")?; }
|
||||||
|
else if self.0.input.len() == 1 && (self.0.input[0].witness.last().unwrap().len() == 138 || self.0.input[0].witness.last().unwrap().len() == 139) && self.0.input[0].witness.len() == 5 { write!(f, "HTLC-success tx")?; }
|
||||||
|
else {
|
||||||
|
for inp in &self.0.input {
|
||||||
|
if inp.witness.last().unwrap().len() == 133 { write!(f, "preimage tx")?; break }
|
||||||
|
else if inp.witness.last().unwrap().len() == 138 { write!(f, "timeout tx")?; break }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! log_tx {
|
||||||
|
($obj: expr) => {
|
||||||
|
::util::macro_logger::DebugTx(&$obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! log_internal {
|
macro_rules! log_internal {
|
||||||
($self: ident, $lvl:expr, $($arg:tt)+) => (
|
($self: ident, $lvl:expr, $($arg:tt)+) => (
|
||||||
&$self.logger.log(&::util::logger::Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()));
|
&$self.logger.log(&::util::logger::Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()));
|
||||||
|
|
Loading…
Add table
Reference in a new issue