Skip to content

Commit a0e8aff

Browse files
committed
Merge bitcoin/bitcoin#25003: tracing: fix coin_selection:aps_create_tx_internal calling logic
6b63673 tracing: fix `coin_selection:aps_create_tx_internal` calling logic (Sebastian Falbesoner) Pull request description: 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. This PR fixes this by moving the tracepoint call and the `use_aps` boolean variable outside the if body. ACKs for top commit: achow101: ACK 6b63673 furszy: re-ACK 6b63673 Tree-SHA512: 453825123aa10748642c7dd94324ced2d07df0f4fac478b0947a34820b515ae300f75721679a90a164f3127029739df55c4de035c4567e663893c3c6dbdef216
2 parents 2642dee + 6b63673 commit a0e8aff

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
@@ -997,12 +997,13 @@ std::optional<CreatedTransactionResult> CreateTransaction(
997997
tmp_cc.m_avoid_partial_spends = true;
998998
bilingual_str error2; // fired and forgotten; if an error occurs, we discard the results
999999
std::optional<CreatedTransactionResult> txr_grouped = CreateTransactionInternal(wallet, vecSend, change_pos, error2, tmp_cc, fee_calc_out, sign);
1000+
// if fee of this alternative one is within the range of the max fee, we use this one
1001+
const bool use_aps{txr_grouped.has_value() ? (txr_grouped->fee <= txr_ungrouped->fee + wallet.m_max_aps_fee) : false};
1002+
TRACE5(coin_selection, aps_create_tx_internal, wallet.GetName().c_str(), use_aps, txr_grouped.has_value(),
1003+
txr_grouped.has_value() ? txr_grouped->fee : 0, txr_grouped.has_value() ? txr_grouped->change_pos : 0);
10001004
if (txr_grouped) {
1001-
// if fee of this alternative one is within the range of the max fee, we use this one
1002-
const bool use_aps = txr_grouped->fee <= txr_ungrouped->fee + wallet.m_max_aps_fee;
10031005
wallet.WalletLogPrintf("Fee non-grouped = %lld, grouped = %lld, using %s\n",
10041006
txr_ungrouped->fee, txr_grouped->fee, use_aps ? "grouped" : "non-grouped");
1005-
TRACE5(coin_selection, aps_create_tx_internal, wallet.GetName().c_str(), use_aps, true, txr_grouped->fee, txr_grouped->change_pos);
10061007
if (use_aps) return txr_grouped;
10071008
}
10081009
}

0 commit comments

Comments
 (0)