From af1af0efb16872e01d8cc63f31d1386c27cbc847 Mon Sep 17 00:00:00 2001 From: chris-belcher Date: Thu, 3 Feb 2022 14:54:35 +0000 Subject: [PATCH] Add log message "seen in mempool " Also added a few debug log messages to the wallet code --- src/taker_protocol.rs | 14 +++++++++++++- src/wallet_sync.rs | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/taker_protocol.rs b/src/taker_protocol.rs index 3651ba1b..7d4005e3 100644 --- a/src/taker_protocol.rs +++ b/src/taker_protocol.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::io::ErrorKind; use std::iter::once; use std::time::Duration; @@ -779,6 +779,7 @@ async fn wait_for_funding_tx_confirmation( "Waiting for funding transaction confirmations ({} conf required)", required_confirmations ); + let mut txids_seen_once = HashSet::::new(); loop { for txid in funding_txids { if txid_tx_map.contains_key(txid) { @@ -789,6 +790,17 @@ async fn wait_for_funding_tx_confirmation( //if we lose connection to the node, just try again, no point returning an error Err(_e) => continue, }; + if !txids_seen_once.contains(txid) { + txids_seen_once.insert(*txid); + if gettx.info.confirmations == 0 { + let mempool_tx = rpc.get_mempool_entry(txid)?; + log::info!( + "Seen in mempool: {} [{:.1} sat/vbyte]", + txid, + mempool_tx.fees.base.as_sat() as f32 / mempool_tx.vsize as f32 + ); + } + } //TODO handle confirm<0 if gettx.info.confirmations >= required_confirmations { txid_tx_map.insert(*txid, deserialize::(&gettx.hex).unwrap()); diff --git a/src/wallet_sync.rs b/src/wallet_sync.rs index a1aef505..69663f85 100644 --- a/src/wallet_sync.rs +++ b/src/wallet_sync.rs @@ -1215,6 +1215,8 @@ impl Wallet { spending_tx: &mut Transaction, inputs_info: &mut dyn Iterator, ) { + log::debug!(target: "wallet", "unsigned spending tx = {:#?}", spending_tx); + let secp = Secp256k1::new(); let master_private_key = self .master_key @@ -1225,6 +1227,7 @@ impl Wallet { for (ix, (mut input, input_info)) in spending_tx.input.iter_mut().zip(inputs_info).enumerate() { + log::debug!(target: "wallet", "signing with input_info = {:#?}", input_info); match input_info { UTXOSpendInfo::SwapCoin { multisig_redeemscript, @@ -1324,6 +1327,7 @@ impl Wallet { //this is the solution used right now let change_addresses = self.get_next_internal_addresses(rpc, destinations.len() as u32)?; + log::debug!(target: "wallet", "change addrs = {:?}", change_addresses); self.lock_all_nonwallet_unspents(rpc)?; let mut output_values = Wallet::generate_amount_fractions( @@ -1346,6 +1350,7 @@ impl Wallet { *output_values.first_mut().unwrap() = coinswap_amount - output_values.iter().skip(1).sum::(); assert_eq!(output_values.iter().sum::(), coinswap_amount); + log::debug!(target: "wallet", "output values = {:?}", output_values); let mut spending_txes = Vec::::new(); let mut payment_output_positions = Vec::::new();