Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…itcoin#19725, bitcoin#19770, bitcoin#19877, bitcoin#20043, partial bitcoin#18878

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
  • Loading branch information
PastaPastaPasta committed May 29, 2024
2 parents 76b8ffd + 34c8047 commit 7596a73
Show file tree
Hide file tree
Showing 24 changed files with 303 additions and 194 deletions.
8 changes: 8 additions & 0 deletions doc/release-notes-18202.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Low-level RPC Changes
---------------------

- 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
6 changes: 6 additions & 0 deletions doc/release-notes-19202.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Updated 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. (#6033)

10 changes: 10 additions & 0 deletions doc/release-notes-19501.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

New settings
------------

Wallet
------

- The `sendtoaddress` and `sendmany` RPCs accept an optional `verbose=True`
argument to also return the fee reason about the sent tx. (#6033)

10 changes: 10 additions & 0 deletions doc/release-notes-19725.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

Updated RPCs
------------

- 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). (#6033)

3 changes: 2 additions & 1 deletion src/coinjoin/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ bool CTransactionBuilder::Commit(bilingual_str& strResult)
CTransactionRef tx;
{
LOCK2(pwallet->cs_wallet, cs_main);
if (!pwallet->CreateTransaction(vecSend, tx, nFeeRet, nChangePosRet, strResult, coinControl)) {
FeeCalculation fee_calc_out;
if (!pwallet->CreateTransaction(vecSend, tx, nFeeRet, nChangePosRet, strResult, coinControl, fee_calc_out)) {
return false;
}
}
Expand Down
10 changes: 1 addition & 9 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,7 @@ void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
bool BCLog::Logger::EnableCategory(const std::string& str)
{
BCLog::LogFlags flag;
if (!GetLogCategory(flag, str)) {
if (str == "db") {
// DEPRECATION: Added in 0.20, should start returning an error in 0.21
LogPrintf("Warning: logging category 'db' is deprecated, use 'walletdb' instead\n");
EnableCategory(BCLog::WALLETDB);
return true;
}
return false;
}
if (!GetLogCategory(flag, str)) return false;
EnableCategory(flag);
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "sendtoaddress", 6, "use_cj" },
{ "sendtoaddress", 7, "conf_target" },
{ "sendtoaddress", 9, "avoid_reuse" },
{ "sendtoaddress", 10, "verbose"},
{ "settxfee", 0, "amount" },
{ "sethdseed", 0, "newkeypool" },
{ "getreceivedbyaddress", 1, "minconf" },
Expand Down Expand Up @@ -89,6 +90,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "sendmany", 6, "use_is" },
{ "sendmany", 7, "use_cj" },
{ "sendmany", 8, "conf_target" },
{ "sendmany", 10, "verbose" },
{ "deriveaddresses", 1, "range" },
{ "scantxoutset", 1, "scanobjects" },
{ "addmultisigaddress", 0, "nrequired" },
Expand Down
3 changes: 2 additions & 1 deletion src/rpc/evo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ static void FundSpecialTx(CWallet* pwallet, CMutableTransaction& tx, const Speci
int nChangePos = -1;
bilingual_str strFailReason;

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

Expand Down
16 changes: 12 additions & 4 deletions src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ static RPCHelpMan getpeerinfo()
{RPCResult::Type::NUM, "version", "The peer version, such as 70001"},
{RPCResult::Type::STR, "subver", "The string version"},
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
{RPCResult::Type::BOOL, "addnode", "Whether connection was due to addnode/-connect or if it was an automatic/inbound connection"},
{RPCResult::Type::BOOL, "addnode", "Whether connection was due to addnode/-connect or if it was an automatic/inbound connection\n"
"(DEPRECATED, returned only if the config option -deprecatedrpc=getpeerinfo_addnode is passed)"},
{RPCResult::Type::BOOL, "masternode", "Whether connection was due to masternode connection attempt"},
{RPCResult::Type::NUM, "banscore", "The ban score (DEPRECATED, returned only if config option -deprecatedrpc=banscore is passed)"},
{RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"},
Expand All @@ -158,7 +159,8 @@ static RPCHelpMan getpeerinfo()
{RPCResult::Type::BOOL, "addr_relay_enabled", "Whether we participate in address relay with this peer"},
{RPCResult::Type::NUM, "addr_processed", "The total number of addresses processed, excluding those dropped due to rate limiting"},
{RPCResult::Type::NUM, "addr_rate_limited", "The total number of addresses dropped due to rate limiting"},
{RPCResult::Type::BOOL, "whitelisted", "Whether the peer is whitelisted"},
{RPCResult::Type::BOOL, "whitelisted", /* optional */ true, "Whether the peer is whitelisted with default permissions\n"
"(DEPRECATED, returned only if config option -deprecatedrpc=whitelisted is passed)"},
{RPCResult::Type::ARR, "permissions", "Any special permissions that have been granted to this peer",
{
{RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"},
Expand Down Expand Up @@ -242,7 +244,10 @@ static RPCHelpMan getpeerinfo()
// their ver message.
obj.pushKV("subver", stats.cleanSubVer);
obj.pushKV("inbound", stats.fInbound);
obj.pushKV("addnode", stats.m_manual_connection);
if (IsDeprecatedRPCEnabled("getpeerinfo_addnode")) {
// addnode is deprecated in v21 for removal in v22
obj.pushKV("addnode", stats.m_manual_connection);
}
obj.pushKV("masternode", stats.m_masternode_connection);
if (fStateStats) {
if (IsDeprecatedRPCEnabled("banscore")) {
Expand All @@ -262,7 +267,10 @@ static RPCHelpMan getpeerinfo()
obj.pushKV("addr_processed", statestats.m_addr_processed);
obj.pushKV("addr_rate_limited", statestats.m_addr_rate_limited);
}
obj.pushKV("whitelisted", stats.m_legacyWhitelisted);
if (IsDeprecatedRPCEnabled("whitelisted")) {
// whitelisted is deprecated in v0.21 for removal in v0.22
obj.pushKV("whitelisted", stats.m_legacyWhitelisted);
}
UniValue permissions(UniValue::VARR);
for (const auto& permission : NetPermissions::ToStrings(stats.m_permissionFlags)) {
permissions.push_back(permission);
Expand Down
3 changes: 2 additions & 1 deletion src/wallet/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ class WalletImpl : public Wallet
LOCK(m_wallet->cs_wallet);
ReserveDestination m_dest(m_wallet.get());
CTransactionRef tx;
FeeCalculation fee_calc_out;
if (!m_wallet->CreateTransaction(recipients, tx, fee, change_pos,
fail_reason, coin_control, sign)) {
fail_reason, coin_control, fee_calc_out, sign)) {
return {};
}
return tx;
Expand Down
Loading

0 comments on commit 7596a73

Please sign in to comment.