Skip to content

Commit 7596a73

Browse files
34c8047 Merge bitcoin#19877: [test] clarify rpc_net & p2p_disconnect_ban functional tests (Wladimir J. van der Laan) e424129 Merge bitcoin#19770: RPC: getpeerinfo: Deprecate "whitelisted" field (replaced by "permissions") (MarcoFalke) f96966b Merge bitcoin#20043: doc: Add 19501 release notes (fanquake) 6a164ea Merge bitcoin#19501: send* RPCs in the wallet returns the "fee reason" (MarcoFalke) b6c8d85 Merge bitcoin#19725: [RPC] Add connection type to getpeerinfo, improve logs (MarcoFalke) f86263b Merge bitcoin#18202: refactor: consolidate sendmany and sendtoaddress code (Samuel Dobson) fab41fd partial Merge bitcoin#18878: test: Add test for conflicted wallet tx notifications (Wladimir J. van der Laan) db5bd34 Merge bitcoin#19202: log: remove deprecated `db` log category (MarcoFalke) Pull request description: ## Issue being fixed or feature implemented Regular backports from bitcoin v21 ## What was done? - bitcoin#19202 - partial bitcoin#18878 - bitcoin#18202 - bitcoin#19725 - bitcoin#19501 - bitcoin#20043 - bitcoin#19770 - bitcoin#19877 ## How Has This Been Tested? Run unit/functional tests ## Breaking Changes - (RPC) The `getpeerinfo` RPC no longer returns the `addnode` field by default. This field will be fully removed in the next major release. It can be accessed with the configuration option `-deprecatedrpc=getpeerinfo_addnode`. However, it is recommended to instead use the `connection_type` field (it will return `manual` when addnode is true) - (Settings) The `sendtoaddress` and `sendmany` RPCs accept an optional `verbose=True` argument to also return the fee reason about the sent tx. - (Settings) The `-debug=db` logging category, which was deprecated in v0.18 and replaced by `-debug=walletdb` to distinguish it from `coindb`, has been removed. - (RPC) To make RPC `sendtoaddress` more consistent with `sendmany` the following error `sendtoaddress` codes were changed from `-4` to `-6`: - Insufficient funds - Fee estimation failed - Transaction has too long of a mempool chain ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: PastaPastaPasta: utACK 34c8047 Tree-SHA512: 725a103e04c9c7d44a79da6f3f54e7745c7fb98ec906e7228ae16f7662d568e48c015c855902ff8485f2908f0f71815e769ca394cf6c3ca2e5fd920dd39cca74
2 parents 76b8ffd + 34c8047 commit 7596a73

24 files changed

+303
-194
lines changed

doc/release-notes-18202.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Low-level RPC Changes
2+
---------------------
3+
4+
- To make RPC `sendtoaddress` more consistent with `sendmany` the following error
5+
`sendtoaddress` codes were changed from `-4` to `-6`:
6+
- Insufficient funds
7+
- Fee estimation failed
8+
- Transaction has too long of a mempool chain

doc/release-notes-19202.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Updated settings
2+
----------------
3+
4+
- The `-debug=db` logging category, which was deprecated in v0.18 and replaced by
5+
`-debug=walletdb` to distinguish it from `coindb`, has been removed. (#6033)
6+

doc/release-notes-19501.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
New settings
3+
------------
4+
5+
Wallet
6+
------
7+
8+
- The `sendtoaddress` and `sendmany` RPCs accept an optional `verbose=True`
9+
argument to also return the fee reason about the sent tx. (#6033)
10+

doc/release-notes-19725.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
Updated RPCs
3+
------------
4+
5+
- The `getpeerinfo` RPC no longer returns the `addnode` field by default. This
6+
field will be fully removed in the next major release. It can be accessed
7+
with the configuration option `-deprecatedrpc=getpeerinfo_addnode`. However,
8+
it is recommended to instead use the `connection_type` field (it will return
9+
`manual` when addnode is true). (#6033)
10+

src/coinjoin/util.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ bool CTransactionBuilder::Commit(bilingual_str& strResult)
274274
CTransactionRef tx;
275275
{
276276
LOCK2(pwallet->cs_wallet, cs_main);
277-
if (!pwallet->CreateTransaction(vecSend, tx, nFeeRet, nChangePosRet, strResult, coinControl)) {
277+
FeeCalculation fee_calc_out;
278+
if (!pwallet->CreateTransaction(vecSend, tx, nFeeRet, nChangePosRet, strResult, coinControl, fee_calc_out)) {
278279
return false;
279280
}
280281
}

src/logging.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,7 @@ void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
9898
bool BCLog::Logger::EnableCategory(const std::string& str)
9999
{
100100
BCLog::LogFlags flag;
101-
if (!GetLogCategory(flag, str)) {
102-
if (str == "db") {
103-
// DEPRECATION: Added in 0.20, should start returning an error in 0.21
104-
LogPrintf("Warning: logging category 'db' is deprecated, use 'walletdb' instead\n");
105-
EnableCategory(BCLog::WALLETDB);
106-
return true;
107-
}
108-
return false;
109-
}
101+
if (!GetLogCategory(flag, str)) return false;
110102
EnableCategory(flag);
111103
return true;
112104
}

src/rpc/client.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
4444
{ "sendtoaddress", 6, "use_cj" },
4545
{ "sendtoaddress", 7, "conf_target" },
4646
{ "sendtoaddress", 9, "avoid_reuse" },
47+
{ "sendtoaddress", 10, "verbose"},
4748
{ "settxfee", 0, "amount" },
4849
{ "sethdseed", 0, "newkeypool" },
4950
{ "getreceivedbyaddress", 1, "minconf" },
@@ -89,6 +90,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
8990
{ "sendmany", 6, "use_is" },
9091
{ "sendmany", 7, "use_cj" },
9192
{ "sendmany", 8, "conf_target" },
93+
{ "sendmany", 10, "verbose" },
9294
{ "deriveaddresses", 1, "range" },
9395
{ "scantxoutset", 1, "scanobjects" },
9496
{ "addmultisigaddress", 0, "nrequired" },

src/rpc/evo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ static void FundSpecialTx(CWallet* pwallet, CMutableTransaction& tx, const Speci
270270
int nChangePos = -1;
271271
bilingual_str strFailReason;
272272

273-
if (!pwallet->CreateTransaction(vecSend, newTx, nFee, nChangePos, strFailReason, coinControl, false, tx.vExtraPayload.size())) {
273+
FeeCalculation fee_calc_out;
274+
if (!pwallet->CreateTransaction(vecSend, newTx, nFee, nChangePos, strFailReason, coinControl, fee_calc_out, false, tx.vExtraPayload.size())) {
274275
throw JSONRPCError(RPC_INTERNAL_ERROR, strFailReason.original);
275276
}
276277

src/rpc/net.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ static RPCHelpMan getpeerinfo()
145145
{RPCResult::Type::NUM, "version", "The peer version, such as 70001"},
146146
{RPCResult::Type::STR, "subver", "The string version"},
147147
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
148-
{RPCResult::Type::BOOL, "addnode", "Whether connection was due to addnode/-connect or if it was an automatic/inbound connection"},
148+
{RPCResult::Type::BOOL, "addnode", "Whether connection was due to addnode/-connect or if it was an automatic/inbound connection\n"
149+
"(DEPRECATED, returned only if the config option -deprecatedrpc=getpeerinfo_addnode is passed)"},
149150
{RPCResult::Type::BOOL, "masternode", "Whether connection was due to masternode connection attempt"},
150151
{RPCResult::Type::NUM, "banscore", "The ban score (DEPRECATED, returned only if config option -deprecatedrpc=banscore is passed)"},
151152
{RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"},
@@ -158,7 +159,8 @@ static RPCHelpMan getpeerinfo()
158159
{RPCResult::Type::BOOL, "addr_relay_enabled", "Whether we participate in address relay with this peer"},
159160
{RPCResult::Type::NUM, "addr_processed", "The total number of addresses processed, excluding those dropped due to rate limiting"},
160161
{RPCResult::Type::NUM, "addr_rate_limited", "The total number of addresses dropped due to rate limiting"},
161-
{RPCResult::Type::BOOL, "whitelisted", "Whether the peer is whitelisted"},
162+
{RPCResult::Type::BOOL, "whitelisted", /* optional */ true, "Whether the peer is whitelisted with default permissions\n"
163+
"(DEPRECATED, returned only if config option -deprecatedrpc=whitelisted is passed)"},
162164
{RPCResult::Type::ARR, "permissions", "Any special permissions that have been granted to this peer",
163165
{
164166
{RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"},
@@ -242,7 +244,10 @@ static RPCHelpMan getpeerinfo()
242244
// their ver message.
243245
obj.pushKV("subver", stats.cleanSubVer);
244246
obj.pushKV("inbound", stats.fInbound);
245-
obj.pushKV("addnode", stats.m_manual_connection);
247+
if (IsDeprecatedRPCEnabled("getpeerinfo_addnode")) {
248+
// addnode is deprecated in v21 for removal in v22
249+
obj.pushKV("addnode", stats.m_manual_connection);
250+
}
246251
obj.pushKV("masternode", stats.m_masternode_connection);
247252
if (fStateStats) {
248253
if (IsDeprecatedRPCEnabled("banscore")) {
@@ -262,7 +267,10 @@ static RPCHelpMan getpeerinfo()
262267
obj.pushKV("addr_processed", statestats.m_addr_processed);
263268
obj.pushKV("addr_rate_limited", statestats.m_addr_rate_limited);
264269
}
265-
obj.pushKV("whitelisted", stats.m_legacyWhitelisted);
270+
if (IsDeprecatedRPCEnabled("whitelisted")) {
271+
// whitelisted is deprecated in v0.21 for removal in v0.22
272+
obj.pushKV("whitelisted", stats.m_legacyWhitelisted);
273+
}
266274
UniValue permissions(UniValue::VARR);
267275
for (const auto& permission : NetPermissions::ToStrings(stats.m_permissionFlags)) {
268276
permissions.push_back(permission);

src/wallet/interfaces.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,9 @@ class WalletImpl : public Wallet
271271
LOCK(m_wallet->cs_wallet);
272272
ReserveDestination m_dest(m_wallet.get());
273273
CTransactionRef tx;
274+
FeeCalculation fee_calc_out;
274275
if (!m_wallet->CreateTransaction(recipients, tx, fee, change_pos,
275-
fail_reason, coin_control, sign)) {
276+
fail_reason, coin_control, fee_calc_out, sign)) {
276277
return {};
277278
}
278279
return tx;

0 commit comments

Comments
 (0)