Skip to content

Commit 6b63673

Browse files
committed
tracing: fix coin_selection:aps_create_tx_internal calling logic
According to the documentation, the tracepoint `coin_selection:aps_create_tx_internal` "Is called when the second `CreateTransactionInternal` with Avoid Partial Spends enabled completes." Currently it is only called if the second call to `CreateTransactionInternal` succeeds, i.e. the third parameter is always `true` and we don't get notified in the case that it fails. Fix this by introducing a boolean variable for the result of the call and moving the tracepoint call outside the if body.
1 parent 1ab389b commit 6b63673

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/wallet/spend.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -993,12 +993,13 @@ std::optional<CreatedTransactionResult> CreateTransaction(
993993
tmp_cc.m_avoid_partial_spends = true;
994994
bilingual_str error2; // fired and forgotten; if an error occurs, we discard the results
995995
std::optional<CreatedTransactionResult> txr_grouped = CreateTransactionInternal(wallet, vecSend, change_pos, error2, tmp_cc, fee_calc_out, sign);
996+
// if fee of this alternative one is within the range of the max fee, we use this one
997+
const bool use_aps{txr_grouped.has_value() ? (txr_grouped->fee <= txr_ungrouped->fee + wallet.m_max_aps_fee) : false};
998+
TRACE5(coin_selection, aps_create_tx_internal, wallet.GetName().c_str(), use_aps, txr_grouped.has_value(),
999+
txr_grouped.has_value() ? txr_grouped->fee : 0, txr_grouped.has_value() ? txr_grouped->change_pos : 0);
9961000
if (txr_grouped) {
997-
// if fee of this alternative one is within the range of the max fee, we use this one
998-
const bool use_aps = txr_grouped->fee <= txr_ungrouped->fee + wallet.m_max_aps_fee;
9991001
wallet.WalletLogPrintf("Fee non-grouped = %lld, grouped = %lld, using %s\n",
10001002
txr_ungrouped->fee, txr_grouped->fee, use_aps ? "grouped" : "non-grouped");
1001-
TRACE5(coin_selection, aps_create_tx_internal, wallet.GetName().c_str(), use_aps, true, txr_grouped->fee, txr_grouped->change_pos);
10021003
if (use_aps) return txr_grouped;
10031004
}
10041005
}

0 commit comments

Comments
 (0)