Skip to content
Merged
2 changes: 1 addition & 1 deletion contrib/seeds/makeseeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def main():
mns = filtermulticollateraladdress(mns)
mns = filtermultipayoutaddress(mns)
# Extract IPs
ips = [parseip(mn['state']['service']) for mn in mns]
ips = [parseip(mn['state']['addresses'][0]) for mn in mns]
for onion in onions:
parsed = parseip(onion)
if parsed is not None:
Expand Down
13 changes: 13 additions & 0 deletions doc/release-notes-6665.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Updated RPCs
------------

* The input field `ipAndPort` has been renamed to `coreP2PAddrs`.
* `coreP2PAddrs` can now, in addition to accepting a string, accept an array of strings, subject to validation rules.

* The key `service` has been deprecated for some RPCs (`decoderawtransaction`, `decodepsbt`, `getblock`, `getrawtransaction`,
`gettransaction`, `masternode status` (only for the `dmnState` key), `protx diff`, `protx listdiff`) and has been replaced
with the field `addresses`.
* The deprecated field can be re-enabled using `-deprecatedrpc=service` but is liable to be removed in future versions
of Dash Core.
* This change does not affect `masternode status` (except for the `dmnState` key) as `service` does not represent a payload
value but the external address advertised by the active masternode.
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ BITCOIN_CORE_H = \
randomenv.h \
rpc/blockchain.h \
rpc/client.h \
rpc/evo_util.h \
rpc/index_util.h \
rpc/mempool.h \
rpc/mining.h \
Expand Down Expand Up @@ -800,6 +801,7 @@ libbitcoin_common_a_SOURCES = \
policy/policy.cpp \
protocol.cpp \
psbt.cpp \
rpc/evo_util.cpp \
rpc/rawtransaction_util.cpp \
rpc/util.cpp \
saltedhasher.cpp \
Expand Down
5 changes: 4 additions & 1 deletion src/coinjoin/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,10 @@ void CCoinJoinClientSession::GetJsonInfo(UniValue& obj) const
assert(mixingMasternode->pdmnState);
obj.pushKV("protxhash", mixingMasternode->proTxHash.ToString());
obj.pushKV("outpoint", mixingMasternode->collateralOutpoint.ToStringShort());
obj.pushKV("service", mixingMasternode->pdmnState->netInfo->GetPrimary().ToStringAddrPort());
if (m_wallet->chain().rpcEnableDeprecated("service")) {
obj.pushKV("service", mixingMasternode->pdmnState->netInfo->GetPrimary().ToStringAddrPort());
}
obj.pushKV("addresses", mixingMasternode->pdmnState->netInfo->ToJson());
}
obj.pushKV("denomination", ValueFromAmount(CoinJoin::DenominationToAmount(nSessionDenom)));
obj.pushKV("state", GetStateString());
Expand Down
10 changes: 8 additions & 2 deletions src/evo/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@
ret.pushKV("type", ToUnderlying(nType));
ret.pushKV("collateralHash", collateralOutpoint.hash.ToString());
ret.pushKV("collateralIndex", (int)collateralOutpoint.n);
ret.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
if (IsServiceDeprecatedRPCEnabled()) {
ret.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
}
ret.pushKV("addresses", netInfo->ToJson());
ret.pushKV("ownerAddress", EncodeDestination(PKHash(keyIDOwner)));
ret.pushKV("votingAddress", EncodeDestination(PKHash(keyIDVoting)));
if (CTxDestination dest; ExtractDestination(scriptPayout, dest)) {
Expand Down Expand Up @@ -114,7 +117,10 @@
ret.pushKV("version", nVersion);
ret.pushKV("type", ToUnderlying(nType));
ret.pushKV("proTxHash", proTxHash.ToString());
ret.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
if (IsServiceDeprecatedRPCEnabled()) {
ret.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
}
ret.pushKV("addresses", netInfo->ToJson());
if (CTxDestination dest; ExtractDestination(scriptOperatorPayout, dest)) {
ret.pushKV("operatorPayoutAddress", EncodeDestination(dest));
}
Expand Down
10 changes: 8 additions & 2 deletions src/evo/dmnstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ UniValue CDeterministicMNState::ToJson(MnType nType) const
{
UniValue obj(UniValue::VOBJ);
obj.pushKV("version", nVersion);
obj.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
if (IsServiceDeprecatedRPCEnabled()) {
obj.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
}
obj.pushKV("addresses", netInfo->ToJson());
obj.pushKV("registeredHeight", nRegisteredHeight);
obj.pushKV("lastPaidHeight", nLastPaidHeight);
obj.pushKV("consecutivePayments", nConsecutivePayments);
Expand Down Expand Up @@ -72,7 +75,10 @@ UniValue CDeterministicMNStateDiff::ToJson(MnType nType) const
obj.pushKV("version", state.nVersion);
}
if (fields & Field_netInfo) {
obj.pushKV("service", state.netInfo->GetPrimary().ToStringAddrPort());
if (IsServiceDeprecatedRPCEnabled()) {
obj.pushKV("service", state.netInfo->GetPrimary().ToStringAddrPort());
}
obj.pushKV("addresses", state.netInfo->ToJson());
}
if (fields & Field_nRegisteredHeight) {
obj.pushKV("registeredHeight", state.nRegisteredHeight);
Expand Down
20 changes: 20 additions & 0 deletions src/evo/netinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <util/check.h>
#include <util/system.h>

#include <univalue.h>

namespace {
static std::unique_ptr<const CChainParams> g_main_params{nullptr};
static std::once_flag g_main_params_flag;
Expand All @@ -33,6 +35,19 @@ bool MatchCharsFilter(std::string_view input, std::string_view filter)
}
} // anonymous namespace

UniValue ArrFromService(const CService& addr)
{
UniValue obj(UniValue::VARR);
obj.push_back(addr.ToStringAddrPort());
return obj;
}

bool IsServiceDeprecatedRPCEnabled()
{
const auto args = gArgs.GetArgs("-deprecatedrpc");
return std::find(args.begin(), args.end(), "service") != args.end();
}

bool NetInfoEntry::operator==(const NetInfoEntry& rhs) const
{
if (m_type != rhs.m_type) return false;
Expand Down Expand Up @@ -227,6 +242,11 @@ NetInfoStatus MnNetInfo::Validate() const
return ValidateService(GetPrimary());
}

UniValue MnNetInfo::ToJson() const
{
return ArrFromService(GetPrimary());
}

std::string MnNetInfo::ToString() const
{
// Extra padding to account for padding done by the calling function.
Expand Down
7 changes: 7 additions & 0 deletions src/evo/netinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

class CService;

class UniValue;

enum class NetInfoStatus : uint8_t {
// Managing entries
BadInput,
Expand Down Expand Up @@ -51,6 +53,9 @@ constexpr std::string_view NISToString(const NetInfoStatus code)
assert(false);
}

/* Identical to IsDeprecatedRPCEnabled("service"). For use outside of RPC code. */
bool IsServiceDeprecatedRPCEnabled();

class NetInfoEntry
{
public:
Expand Down Expand Up @@ -141,6 +146,7 @@ class NetInfoInterface
virtual bool CanStorePlatform() const = 0;
virtual bool IsEmpty() const = 0;
virtual NetInfoStatus Validate() const = 0;
virtual UniValue ToJson() const = 0;
virtual std::string ToString() const = 0;

virtual void Clear() = 0;
Expand Down Expand Up @@ -197,6 +203,7 @@ class MnNetInfo final : public NetInfoInterface
bool IsEmpty() const override { return m_addr.IsEmpty(); }
bool CanStorePlatform() const override { return false; }
NetInfoStatus Validate() const override;
UniValue ToJson() const override;
std::string ToString() const override;

void Clear() override { m_addr.Clear(); }
Expand Down
10 changes: 7 additions & 3 deletions src/evo/simplifiedmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

#include <evo/simplifiedmns.h>

#include <evo/cbtx.h>
#include <core_io.h>
#include <deploymentstatus.h>
#include <evo/cbtx.h>
#include <evo/deterministicmns.h>
#include <evo/netinfo.h>
#include <evo/specialtx.h>
#include <llmq/blockprocessor.h>
#include <llmq/commitment.h>
#include <llmq/quorums.h>
#include <node/blockstorage.h>
#include <evo/specialtx.h>

#include <pubkey.h>
#include <serialize.h>
Expand Down Expand Up @@ -80,7 +81,10 @@ UniValue CSimplifiedMNListEntry::ToJson(bool extended) const
obj.pushKV("nType", ToUnderlying(nType));
obj.pushKV("proRegTxHash", proRegTxHash.ToString());
obj.pushKV("confirmedHash", confirmedHash.ToString());
obj.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
if (IsServiceDeprecatedRPCEnabled()) {
obj.pushKV("service", netInfo->GetPrimary().ToStringAddrPort());
}
obj.pushKV("addresses", netInfo->ToJson());
obj.pushKV("pubKeyOperator", pubKeyOperator.ToString());
obj.pushKV("votingAddress", EncodeDestination(PKHash(keyIDVoting)));
obj.pushKV("isValid", isValid);
Expand Down
8 changes: 7 additions & 1 deletion src/rpc/coinjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,13 @@ static RPCHelpMan getcoinjoininfo()
{
{RPCResult::Type::STR_HEX, "protxhash", "The ProTxHash of the masternode"},
{RPCResult::Type::STR_HEX, "outpoint", "The outpoint of the masternode"},
{RPCResult::Type::STR, "service", "The IP address and port of the masternode"},
{RPCResult::Type::STR, "service", "The IP address and port of the masternode (DEPRECATED, returned only if config option -deprecatedrpc=service is passed)"},
{RPCResult::Type::ARR, "addresses", "Network addresses of the masternode",
{
{
{RPCResult::Type::STR, "address", ""},
}
}},
{RPCResult::Type::NUM, "denomination", "The denomination of the mixing session in " + CURRENCY_UNIT + ""},
{RPCResult::Type::STR_HEX, "state", "Current state of the mixing session"},
{RPCResult::Type::NUM, "entries_count", "The number of entries in the mixing session"},
Expand Down
Loading
Loading