Skip to content

Commit

Permalink
Add log message "seen in mempool <fee rate>"
Browse files Browse the repository at this point in the history
Also added a few debug log messages to the wallet code
  • Loading branch information
chris-belcher committed Feb 3, 2022
1 parent 14f0621 commit af1af0e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/taker_protocol.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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::<Txid>::new();
loop {
for txid in funding_txids {
if txid_tx_map.contains_key(txid) {
Expand All @@ -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::<Transaction>(&gettx.hex).unwrap());
Expand Down
5 changes: 5 additions & 0 deletions src/wallet_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,8 @@ impl Wallet {
spending_tx: &mut Transaction,
inputs_info: &mut dyn Iterator<Item = UTXOSpendInfo>,
) {
log::debug!(target: "wallet", "unsigned spending tx = {:#?}", spending_tx);

let secp = Secp256k1::new();
let master_private_key = self
.master_key
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -1346,6 +1350,7 @@ impl Wallet {
*output_values.first_mut().unwrap() =
coinswap_amount - output_values.iter().skip(1).sum::<u64>();
assert_eq!(output_values.iter().sum::<u64>(), coinswap_amount);
log::debug!(target: "wallet", "output values = {:?}", output_values);

let mut spending_txes = Vec::<Transaction>::new();
let mut payment_output_positions = Vec::<u32>::new();
Expand Down

0 comments on commit af1af0e

Please sign in to comment.