From 689a360b607095274ce960b3078c8524455531df Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 18 Apr 2022 00:32:11 -0400 Subject: [PATCH] Allow notary addresses in sendmany, fixes #126 --- src/wallet/rpcwallet.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 80064f6b2..edfb608e7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1502,8 +1502,6 @@ UniValue sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) "\nAs a json rpc call\n" + HelpExampleRpc("sendmany", "\"\", {\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY\":0.01,\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\":0.02}, 6, \"testing\"") ); - if ( ASSETCHAINS_PRIVATE != 0 ) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "cant use transparent addresses in private chain"); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1528,6 +1526,17 @@ UniValue sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) std::vector keys = sendTo.getKeys(); int32_t i = 0; for (const std::string& name_ : keys) { + // Allow transparent notary addresses and throw an error for anything else + // This is also a consensus check but we want to prevent it from going into the mempool + // and give an error as early as possible + if ( ASSETCHAINS_PRIVATE != 0 ) + { + if ( hush_isnotaryvout((char *)name_.c_str(),chainActive.LastTip()->nTime) == 0 ) + { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transparent " + strprintf("%s",hush_chainname()) + " address not allowed on private chain"); + } + } + CTxDestination dest = DecodeDestination(name_); if (!IsValidDestination(dest)) { CScript tmpspk;