Skip to content

Commit 0831173

Browse files
committed
Merge bitcoin/bitcoin#34640: wallet: rpc: Improve error message for low feerates.
98fcd7a wallet: rpc: Improve error message for low feerates. (David Gumberg) Pull request description: Giving the user a hint about what action to take when they encounter an error related to a feerate that is below the minimum. I encountered this myself not knowing about `-mintxfee` and the manpage was slightly less than clear, ``` -mintxfee=<amt> Fee rates (in BTC/kvB) smaller than this are considered zero fee for transaction creation (default: 0.00001) ``` ACKs for top commit: achow101: ACK 98fcd7a ismaelsadeeq: ACK 98fcd7a w0xlt: ACK 98fcd7a Tree-SHA512: 8471bfd5682ca59137541ab4da670e85947cf7812baa9e07d816e352fccfb5e0e71a06c2baf1a5422d78a7da8c08b9fcbb73d85cc9daba88b7c22e802abe5b2e
2 parents d0ed369 + 98fcd7a commit 0831173

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/wallet/rpc/spend.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,16 @@ RPCMethod sendall()
14311431
// Do not, ever, assume that it's fine to change the fee rate if the user has explicitly
14321432
// provided one
14331433
if (coin_control.m_feerate && fee_rate > *coin_control.m_feerate) {
1434-
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Fee rate (%s) is lower than the minimum fee rate setting (%s)", coin_control.m_feerate->ToString(FeeRateFormat::SAT_VB), fee_rate.ToString(FeeRateFormat::SAT_VB)));
1434+
const auto feerate_format = FeeRateFormat::SAT_VB;
1435+
auto msg{strprintf("Fee rate (%s) is lower than the minimum fee rate setting (%s).",
1436+
coin_control.m_feerate->ToString(feerate_format),
1437+
fee_rate.ToString(feerate_format))};
1438+
if (fee_calc_out.reason == FeeReason::REQUIRED) {
1439+
msg += strprintf("\nConsider modifying -mintxfee (%s) or -minrelaytxfee (%s).",
1440+
pwallet->m_min_fee.ToString(feerate_format),
1441+
pwallet->chain().relayMinFee().ToString(feerate_format));
1442+
}
1443+
throw JSONRPCError(RPC_INVALID_PARAMETER, msg);
14351444
}
14361445
if (fee_calc_out.reason == FeeReason::FALLBACK && !pwallet->m_allow_fallback_fee) {
14371446
// eventually allow a fallback fee

src/wallet/spend.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,18 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
11591159
// Do not, ever, assume that it's fine to change the fee rate if the user has explicitly
11601160
// provided one
11611161
if (coin_control.m_feerate && coin_selection_params.m_effective_feerate > *coin_control.m_feerate) {
1162-
return util::Error{strprintf(_("Fee rate (%s) is lower than the minimum fee rate setting (%s)"), coin_control.m_feerate->ToString(FeeRateFormat::SAT_VB), coin_selection_params.m_effective_feerate.ToString(FeeRateFormat::SAT_VB))};
1162+
const auto feerate_format = FeeRateFormat::SAT_VB;
1163+
auto msg{strprintf(_("Fee rate (%s) is lower than the minimum fee rate setting (%s)."),
1164+
coin_control.m_feerate->ToString(feerate_format),
1165+
coin_selection_params.m_effective_feerate.ToString(feerate_format))};
1166+
if (feeCalc.reason == FeeReason::REQUIRED) {
1167+
msg += strprintf(_("\nConsider modifying %s (%s) or %s (%s)."),
1168+
"-mintxfee",
1169+
wallet.m_min_fee.ToString(feerate_format),
1170+
"-minrelaytxfee",
1171+
wallet.chain().relayMinFee().ToString(feerate_format));
1172+
}
1173+
return util::Error{msg};
11631174
}
11641175
if (feeCalc.reason == FeeReason::FALLBACK && !wallet.m_allow_fallback_fee) {
11651176
// eventually allow a fallback fee

0 commit comments

Comments
 (0)