diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index a04851aaa35d8..697779071bca1 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -106,8 +106,8 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex) result.pushKV("difficulty", GetDifficulty(blockindex)); result.pushKV("chainwork", blockindex->nChainWork.GetHex()); result.pushKV("acc_checkpoint", blockindex->nAccumulatorCheckpoint.GetHex()); - // Sapling shielded pool value - result.pushKV("shielded_pool_value", ValuePoolDesc(blockindex->nChainSaplingValue, blockindex->nSaplingValue)); + // Sapling shield pool value + result.pushKV("shield_pool_value", ValuePoolDesc(blockindex->nChainSaplingValue, blockindex->nSaplingValue)); if (blockindex->pprev) result.pushKV("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()); CBlockIndex *pnext = chainActive.Next(blockindex); @@ -594,7 +594,7 @@ UniValue getblockheader(const JSONRPCRequest& request) " \"mediantime\" : ttt, (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)\n" " \"nonce\" : n, (numeric) The nonce\n" " \"bits\" : \"1d00ffff\", (string) The bits\n" - " \"shielded_pool_value\": (object) Block shielded pool value\n" + " \"shield_pool_value\": (object) Block shield pool value\n" " {\n" " \"chainValue\": (numeric) Total value held by the Sapling circuit up to and including this block\n" " \"valueDelta\": (numeric) Change in value held by the Sapling circuit over this block\n" @@ -650,8 +650,8 @@ UniValue getsupplyinfo(const JSONRPCRequest& request) "{\n" " \"updateheight\" : n, (numeric) The chain height when the transparent supply was updated\n" " \"transparentsupply\" : n (numeric) The sum of all spendable transaction outputs at height updateheight\n" - " \"shieldedsupply\": n (numeric) Chain tip shielded pool value\n" - " \"totalsupply\": n (numeric) The sum of transparentsupply and shieldedsupply\n" + " \"shieldsupply\": n (numeric) Chain tip shield pool value\n" + " \"totalsupply\": n (numeric) The sum of transparentsupply and shieldsupply\n" "}\n" "\nExamples:\n" + @@ -670,7 +670,7 @@ UniValue getsupplyinfo(const JSONRPCRequest& request) ret.pushKV("updateheight", MoneySupply.GetCacheHeight()); ret.pushKV("transparentsupply", ValueFromAmount(tSupply)); Optional shieldedPoolValue = WITH_LOCK(cs_main, return (chainActive.Tip() ? chainActive.Tip()->nChainSaplingValue : nullopt); ); - ret.pushKV("shieldedsupply", ValuePoolDesc(shieldedPoolValue, nullopt)["chainValue"]); + ret.pushKV("shieldsupply", ValuePoolDesc(shieldedPoolValue, nullopt)["chainValue"]); const CAmount totalSupply = tSupply + (shieldedPoolValue ? *shieldedPoolValue : 0); ret.pushKV("totalsupply", ValueFromAmount(totalSupply)); @@ -980,7 +980,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" " \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n" " \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n" - " \"shielded_pool_value\": (object) Chain tip shielded pool value\n" + " \"shield_pool_value\": (object) Chain tip shield pool value\n" " \"initial_block_downloading\" (boolean) whether the node is in initial block downloading state or not" " {\n" " \"chainValue\": (numeric) Total value held by the Sapling circuit up to and including the chain tip\n" @@ -1020,8 +1020,8 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) obj.pushKV("difficulty", (double)GetDifficulty()); obj.pushKV("verificationprogress", Checkpoints::GuessVerificationProgress(pChainTip)); obj.pushKV("chainwork", pChainTip ? pChainTip->nChainWork.GetHex() : ""); - // Sapling shielded pool value - obj.pushKV("shielded_pool_value", ValuePoolDesc(pChainTip->nChainSaplingValue, pChainTip->nSaplingValue)); + // Sapling shield pool value + obj.pushKV("shield_pool_value", ValuePoolDesc(pChainTip->nChainSaplingValue, pChainTip->nSaplingValue)); obj.pushKV("initial_block_downloading", IsInitialBlockDownload()); UniValue softforks(UniValue::VARR); softforks.push_back(SoftForkDesc("bip65", 5, pChainTip)); diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 69862e3ff33fe..e74732d70bb22 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -39,7 +39,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { { "sendtoaddress", 1 }, { "settxfee", 0 }, { "getreceivedbyaddress", 1 }, - { "listreceivedbyshieldedaddress", 1 }, + { "listreceivedbyshieldaddress", 1 }, { "getreceivedbylabel", 1 }, { "listcoldutxos", 0 }, { "listdelegators", 0 }, @@ -54,14 +54,14 @@ static const CRPCConvertParam vRPCConvertParams[] = { { "getbalance", 2 }, { "getbalance", 3 }, { "getbalance", 4 }, - { "getshieldedbalance", 1 }, - { "getshieldedbalance", 2 }, - { "rawshieldedsendmany", 1 }, - { "rawshieldedsendmany", 2 }, - { "rawshieldedsendmany", 3 }, - { "shieldedsendmany", 1 }, - { "shieldedsendmany", 2 }, - { "shieldedsendmany", 3 }, + { "getshieldbalance", 1 }, + { "getshieldbalance", 2 }, + { "rawshieldsendmany", 1 }, + { "rawshieldsendmany", 2 }, + { "rawshieldsendmany", 3 }, + { "shieldsendmany", 1 }, + { "shieldsendmany", 2 }, + { "shieldsendmany", 3 }, { "getblockhash", 0 }, { "waitforblockheight", 0 }, { "waitforblockheight", 1 }, @@ -89,10 +89,10 @@ static const CRPCConvertParam vRPCConvertParams[] = { { "listunspent", 1 }, { "listunspent", 2 }, { "listunspent", 3 }, - { "listshieldedunspent", 0 }, - { "listshieldedunspent", 1 }, - { "listshieldedunspent", 2 }, - { "listshieldedunspent", 3 }, + { "listshieldunspent", 0 }, + { "listshieldunspent", 1 }, + { "listshieldunspent", 2 }, + { "listshieldunspent", 3 }, { "logging", 0 }, { "logging", 1 }, { "getblock", 1 }, diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index ae6f48292e33f..7b1d747eea8a1 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -71,7 +71,7 @@ UniValue getinfo(const JSONRPCRequest& request) " \"transparentsupply\" : n (numeric) The sum of the value of all unspent outputs when the chainstate was\n" " last flushed to disk (use getsupplyinfo to know the update-height, or\n" " to trigger the money supply update/recalculation)" - " \"shieldedsupply\": n (numeric) Chain tip shielded pool value\n" + " \"shieldsupply\": n (numeric) Chain tip shield pool value\n" " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n" " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n" " \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n" @@ -133,7 +133,7 @@ UniValue getinfo(const JSONRPCRequest& request) UniValue supply_info = getsupplyinfo(JSONRPCRequest()); obj.pushKV("moneysupply", supply_info["totalsupply"]); obj.pushKV("transparentsupply", supply_info["transparentsupply"]); - obj.pushKV("shieldedsupply", supply_info["shieldedsupply"]); + obj.pushKV("shieldsupply", supply_info["shieldsupply"]); #ifdef ENABLE_WALLET if (pwalletMain) { diff --git a/src/sapling/saplingscriptpubkeyman.cpp b/src/sapling/saplingscriptpubkeyman.cpp index 6498affc4e3d2..8053cecff0ec5 100644 --- a/src/sapling/saplingscriptpubkeyman.cpp +++ b/src/sapling/saplingscriptpubkeyman.cpp @@ -634,7 +634,7 @@ OptionalvShieldedSpend) { @@ -762,7 +762,7 @@ bool SaplingScriptPubKeyMan::IsNoteSaplingChange(const std::setmapWallet[op.hash]; if (tx.sapData) { diff --git a/src/test/librust/sapling_rpc_wallet_tests.cpp b/src/test/librust/sapling_rpc_wallet_tests.cpp index 630ace9499c53..ccb56ba9433e7 100644 --- a/src/test/librust/sapling_rpc_wallet_tests.cpp +++ b/src/test/librust/sapling_rpc_wallet_tests.cpp @@ -89,24 +89,24 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_getbalance) LOCK2(cs_main, pwalletMain->cs_wallet); - BOOST_CHECK_THROW(CallRPC("getshieldedbalance too many args"), std::runtime_error); - BOOST_CHECK_THROW(CallRPC("getshieldedbalance invalidaddress"), std::runtime_error); - BOOST_CHECK_THROW(CallRPC("getshieldedbalance tmC6YZnCUhm19dEXxh3Jb7srdBJxDawaCab"), std::runtime_error); - BOOST_CHECK_NO_THROW(CallRPC("getshieldedbalance ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh")); - BOOST_CHECK_THROW(CallRPC("getshieldedbalance ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh -1"), std::runtime_error); - BOOST_CHECK_NO_THROW(CallRPC("getshieldedbalance ptestsapling1nrn6exksuqtpld9gu6fwdz4hwg54h2x37gutdds89pfyg6mtjf63km45a8eare5qla45cj75vs8 0")); - BOOST_CHECK_THROW(CallRPC("getshieldedbalance tnRZ8bPq2pff3xBWhTJhNkVUkm2uhzksDeW5PvEa7aFKGT9Qi3YgTALZfjaY4jU3HLVKBtHdSXxoPoLA3naMPcHBcY88FcF 1"), std::runtime_error); - BOOST_CHECK_NO_THROW(CallRPC("getshieldedbalance *")); - BOOST_CHECK_NO_THROW(CallRPC("getshieldedbalance * 6")); - BOOST_CHECK_THROW(CallRPC("getshieldedbalance * -1"), std::runtime_error); - - BOOST_CHECK_THROW(CallRPC("listreceivedbyshieldedaddress too many args"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("getshieldbalance too many args"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("getshieldbalance invalidaddress"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("getshieldbalance tmC6YZnCUhm19dEXxh3Jb7srdBJxDawaCab"), std::runtime_error); + BOOST_CHECK_NO_THROW(CallRPC("getshieldbalance ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh")); + BOOST_CHECK_THROW(CallRPC("getshieldbalance ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh -1"), std::runtime_error); + BOOST_CHECK_NO_THROW(CallRPC("getshieldbalance ptestsapling1nrn6exksuqtpld9gu6fwdz4hwg54h2x37gutdds89pfyg6mtjf63km45a8eare5qla45cj75vs8 0")); + BOOST_CHECK_THROW(CallRPC("getshieldbalance tnRZ8bPq2pff3xBWhTJhNkVUkm2uhzksDeW5PvEa7aFKGT9Qi3YgTALZfjaY4jU3HLVKBtHdSXxoPoLA3naMPcHBcY88FcF 1"), std::runtime_error); + BOOST_CHECK_NO_THROW(CallRPC("getshieldbalance *")); + BOOST_CHECK_NO_THROW(CallRPC("getshieldbalance * 6")); + BOOST_CHECK_THROW(CallRPC("getshieldbalance * -1"), std::runtime_error); + + BOOST_CHECK_THROW(CallRPC("listreceivedbyshieldaddress too many args"), std::runtime_error); // negative minconf not allowed - BOOST_CHECK_THROW(CallRPC("listreceivedbyshieldedaddress yBYhwgzufrZ6F5VVuK9nEChENArq934mqC -1"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listreceivedbyshieldaddress yBYhwgzufrZ6F5VVuK9nEChENArq934mqC -1"), std::runtime_error); // invalid zaddr, taddr not allowed - BOOST_CHECK_THROW(CallRPC("listreceivedbyshieldedaddress yBYhwgzufrZ6F5VVuK9nEChENArq934mqC 0"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listreceivedbyshieldaddress yBYhwgzufrZ6F5VVuK9nEChENArq934mqC 0"), std::runtime_error); // don't have the spending key - BOOST_CHECK_THROW(CallRPC("listreceivedbyshieldedaddress ptestsapling1nrn6exksuqtpld9gu6fwdz4hwg54h2x37gutdds89pfyg6mtjf63km45a8eare5qla45cj75vs8 1"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listreceivedbyshieldaddress ptestsapling1nrn6exksuqtpld9gu6fwdz4hwg54h2x37gutdds89pfyg6mtjf63km45a8eare5qla45cj75vs8 1"), std::runtime_error); } BOOST_AUTO_TEST_CASE(rpc_wallet_sapling_importkey_paymentaddress) { @@ -183,7 +183,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_sapling_importexport) } // Verify we can list the keys imported - BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldedaddresses")); + BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldaddresses")); UniValue arr = retValue.get_array(); BOOST_CHECK((int) arr.size() == n1); @@ -205,7 +205,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_sapling_importexport) BOOST_CHECK((int) saplingAddrs.size() == numAddrs); // Ask wallet to list addresses - BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldedaddresses")); + BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldaddresses")); arr = retValue.get_array(); BOOST_CHECK((int) arr.size() == numAddrs); @@ -230,7 +230,7 @@ void CheckHaveAddr(const libzcash::PaymentAddress& addr) { BOOST_CHECK(pwalletMain->HaveSpendingKeyForPaymentAddress(*addr_of_type)); } -BOOST_AUTO_TEST_CASE(rpc_wallet_getnewshieldedaddress) { +BOOST_AUTO_TEST_CASE(rpc_wallet_getnewshieldaddress) { UniValue addr; { LOCK(pwalletMain->cs_wallet); @@ -239,57 +239,57 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_getnewshieldedaddress) { } // No parameter defaults to sapling address - addr = CallRPC("getnewshieldedaddress"); + addr = CallRPC("getnewshieldaddress"); CheckHaveAddr(KeyIO::DecodePaymentAddress(addr.get_str())); // Too many arguments will throw with the help - BOOST_CHECK_THROW(CallRPC("getnewshieldedaddress many args"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("getnewshieldaddress many args"), std::runtime_error); } -BOOST_AUTO_TEST_CASE(rpc_shieldedsendmany_parameters) +BOOST_AUTO_TEST_CASE(rpc_shieldsendmany_parameters) { SelectParams(CBaseChainParams::TESTNET); LOCK2(cs_main, pwalletMain->cs_wallet); - BOOST_CHECK_THROW(CallRPC("shieldedsendmany"), std::runtime_error); - BOOST_CHECK_THROW(CallRPC("shieldedsendmany toofewargs"), std::runtime_error); - BOOST_CHECK_THROW(CallRPC("shieldedsendmany just too many args here"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("shieldsendmany"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("shieldsendmany toofewargs"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("shieldsendmany just too many args here"), std::runtime_error); // bad from address - BOOST_CHECK_THROW(CallRPC("shieldedsendmany " + BOOST_CHECK_THROW(CallRPC("shieldsendmany " "INVALIDyBYhwgzufrZ6F5VVuK9nEChENArq934mqC []"), std::runtime_error); // empty amounts - BOOST_CHECK_THROW(CallRPC("shieldedsendmany " + BOOST_CHECK_THROW(CallRPC("shieldsendmany " "yBYhwgzufrZ6F5VVuK9nEChENArq934mqC []"), std::runtime_error); // don't have the spending key for this address - BOOST_CHECK_THROW(CallRPC("shieldedsendmany " + BOOST_CHECK_THROW(CallRPC("shieldsendmany " "ptestsapling1wpurflqllgkcs48m46yu9ktlfe3ahndely20dpaanqq3lw9l5xw7yfehst68yclvlpz7x8cltxe" "UkJ1oSfbhTJhm72WiZizvkZz5aH1 []"), std::runtime_error); // duplicate address - BOOST_CHECK_THROW(CallRPC("shieldedsendmany " + BOOST_CHECK_THROW(CallRPC("shieldsendmany " "yBYhwgzufrZ6F5VVuK9nEChENArq934mqC " "[{\"address\":\"yAJ4bGeDFcEtx24kbr413fBLpWQcdR5F2z\", \"amount\":50.0}," " {\"address\":\"yAJ4bGeDFcEtx24kbr413fBLpWQcdR5F2z\", \"amount\":12.0} ]" ), std::runtime_error); // invalid fee amount, cannot be negative - BOOST_CHECK_THROW(CallRPC("shieldedsendmany " + BOOST_CHECK_THROW(CallRPC("shieldsendmany " "yBYhwgzufrZ6F5VVuK9nEChENArq934mqC " "[{\"address\":\"yAJ4bGeDFcEtx24kbr413fBLpWQcdR5F2z\", \"amount\":50.0}] " "1 -0.0001" ), std::runtime_error); // invalid fee amount, bigger than MAX_MONEY - BOOST_CHECK_THROW(CallRPC("shieldedsendmany " + BOOST_CHECK_THROW(CallRPC("shieldsendmany " "yBYhwgzufrZ6F5VVuK9nEChENArq934mqC " "[{\"address\":\"yAJ4bGeDFcEtx24kbr413fBLpWQcdR5F2z\", \"amount\":50.0}] " "1 21000001" ), std::runtime_error); // fee amount is bigger than sum of outputs - BOOST_CHECK_THROW(CallRPC("shieldedsendmany " + BOOST_CHECK_THROW(CallRPC("shieldsendmany " "yBYhwgzufrZ6F5VVuK9nEChENArq934mqC " "[{\"address\":\"yAJ4bGeDFcEtx24kbr413fBLpWQcdR5F2z\", \"amount\":50.0}] " "1 50.00000001" @@ -302,7 +302,7 @@ BOOST_AUTO_TEST_CASE(rpc_shieldedsendmany_parameters) pwalletMain->SetupSPKM(false); auto pa = pwalletMain->GenerateNewSaplingZKey(); std::string zaddr1 = KeyIO::EncodePaymentAddress(pa); - BOOST_CHECK_THROW(CallRPC(std::string("shieldedsendmany yBYhwgzufrZ6F5VVuK9nEChENArq934mqC ") + BOOST_CHECK_THROW(CallRPC(std::string("shieldsendmany yBYhwgzufrZ6F5VVuK9nEChENArq934mqC ") + "[{\"address\":\"" + zaddr1 + "\", \"amount\":123.456}]"), std::runtime_error); } @@ -385,7 +385,7 @@ BOOST_AUTO_TEST_CASE(saplingOperationTests) { } -BOOST_AUTO_TEST_CASE(rpc_shieldedsendmany_taddr_to_sapling) +BOOST_AUTO_TEST_CASE(rpc_shieldsendmany_taddr_to_sapling) { SelectParams(CBaseChainParams::REGTEST); RegtestActivateSapling(); @@ -427,7 +427,7 @@ BOOST_AUTO_TEST_CASE(rpc_shieldedsendmany_taddr_to_sapling) wtx.SetMerkleBranch(blockHash, 0); pwalletMain->LoadToWallet(wtx); - // Context that shieldedsendmany requires + // Context that shieldsendmany requires auto builder = TransactionBuilder(consensusParams, nextBlockHeight, pwalletMain); std::vector recipients = { SendManyRecipient(zaddr1, 1 * COIN, "ABCD") }; @@ -494,11 +494,11 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_encrypted_wallet_sapzkeys) // create keys for (int i = 0; i < n; i++) { - CallRPC("getnewshieldedaddress"); + CallRPC("getnewshieldaddress"); } // Verify we can list the keys imported - BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldedaddresses")); + BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldaddresses")); UniValue arr = retValue.get_array(); BOOST_CHECK((int) arr.size() == n); @@ -515,22 +515,22 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_encrypted_wallet_sapzkeys) BOOST_CHECK(pwalletMain->EncryptWallet(strWalletPass)); // Verify we can still list the keys imported - BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldedaddresses")); + BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldaddresses")); arr = retValue.get_array(); BOOST_CHECK((int) arr.size() == n); // Try to add a new key, but we can't as the wallet is locked - BOOST_CHECK_THROW(CallRPC("getnewshieldedaddress"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("getnewshieldaddress"), std::runtime_error); // We can't call RPC walletpassphrase as that invokes RPCRunLater which breaks tests. // So we manually unlock. BOOST_CHECK(pwalletMain->Unlock(strWalletPass)); // Now add a key - BOOST_CHECK_NO_THROW(CallRPC("getnewshieldedaddress")); + BOOST_CHECK_NO_THROW(CallRPC("getnewshieldaddress")); // Verify the key has been added - BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldedaddresses")); + BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldaddresses")); arr = retValue.get_array(); BOOST_CHECK((int) arr.size() == n+1); @@ -538,7 +538,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_encrypted_wallet_sapzkeys) // but there are tests for this in gtest. } -BOOST_AUTO_TEST_CASE(rpc_listshieldedunspent_parameters) +BOOST_AUTO_TEST_CASE(rpc_listshieldunspent_parameters) { SelectParams(CBaseChainParams::TESTNET); @@ -548,43 +548,43 @@ BOOST_AUTO_TEST_CASE(rpc_listshieldedunspent_parameters) UniValue retValue; // too many args - BOOST_CHECK_THROW(CallRPC("listshieldedunspent 1 2 3 4 5"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listshieldunspent 1 2 3 4 5"), std::runtime_error); // minconf must be >= 0 - BOOST_CHECK_THROW(CallRPC("listshieldedunspent -1"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listshieldunspent -1"), std::runtime_error); // maxconf must be > minconf - BOOST_CHECK_THROW(CallRPC("listshieldedunspent 2 1"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listshieldunspent 2 1"), std::runtime_error); // maxconf must not be out of range - BOOST_CHECK_THROW(CallRPC("listshieldedunspent 1 9999999999"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listshieldunspent 1 9999999999"), std::runtime_error); // must be an array of addresses - BOOST_CHECK_THROW(CallRPC("listshieldedunspent 1 999 false ptestsapling1wpurflqllgkcs48m46yu9ktlfe3ahndely20dpaanqq3lw9l5xw7yfehst68yclvlpz7x8cltxe"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listshieldunspent 1 999 false ptestsapling1wpurflqllgkcs48m46yu9ktlfe3ahndely20dpaanqq3lw9l5xw7yfehst68yclvlpz7x8cltxe"), std::runtime_error); // address must be string - BOOST_CHECK_THROW(CallRPC("listshieldedunspent 1 999 false [123456]"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listshieldunspent 1 999 false [123456]"), std::runtime_error); // no spending key - BOOST_CHECK_THROW(CallRPC("listshieldedunspent 1 999 false [\"ptestsapling1wpurflqllgkcs48m46yu9ktlfe3ahndely20dpaanqq3lw9l5xw7yfehst68yclvlpz7x8cltxe\"]"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listshieldunspent 1 999 false [\"ptestsapling1wpurflqllgkcs48m46yu9ktlfe3ahndely20dpaanqq3lw9l5xw7yfehst68yclvlpz7x8cltxe\"]"), std::runtime_error); // allow watch only - BOOST_CHECK_NO_THROW(CallRPC("listshieldedunspent 1 999 true [\"ptestsapling1wpurflqllgkcs48m46yu9ktlfe3ahndely20dpaanqq3lw9l5xw7yfehst68yclvlpz7x8cltxe\"]")); + BOOST_CHECK_NO_THROW(CallRPC("listshieldunspent 1 999 true [\"ptestsapling1wpurflqllgkcs48m46yu9ktlfe3ahndely20dpaanqq3lw9l5xw7yfehst68yclvlpz7x8cltxe\"]")); // wrong network, mainnet instead of testnet - BOOST_CHECK_THROW(CallRPC("listshieldedunspent 1 999 true [\"ps1qenk9kapr0crx7lmdl4yclx78spc36wh7d5hm9hglp85f43k9dupyf0c5836h42wq2ejv0ef2v3\"]"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listshieldunspent 1 999 true [\"ps1qenk9kapr0crx7lmdl4yclx78spc36wh7d5hm9hglp85f43k9dupyf0c5836h42wq2ejv0ef2v3\"]"), std::runtime_error); // create shielded address so we have the spending key - BOOST_CHECK_NO_THROW(retValue = CallRPC("getnewshieldedaddress")); + BOOST_CHECK_NO_THROW(retValue = CallRPC("getnewshieldaddress")); std::string myzaddr = retValue.get_str(); // return empty array for this address - BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldedunspent 1 999 false [\"" + myzaddr + "\"]")); + BOOST_CHECK_NO_THROW(retValue = CallRPC("listshieldunspent 1 999 false [\"" + myzaddr + "\"]")); UniValue arr = retValue.get_array(); BOOST_CHECK_EQUAL(0, arr.size()); // duplicate address error - BOOST_CHECK_THROW(CallRPC("listshieldedunspent 1 999 false [\"" + myzaddr + "\", \"" + myzaddr + "\"]"), std::runtime_error); + BOOST_CHECK_THROW(CallRPC("listshieldunspent 1 999 false [\"" + myzaddr + "\", \"" + myzaddr + "\"]"), std::runtime_error); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 53b0301aa83a6..446d18e9ccd96 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -501,18 +501,18 @@ UniValue getnewstakingaddress(const JSONRPCRequest& request) return EncodeDestination(GetNewAddressFromLabel("coldstaking", request.params, CChainParams::STAKING_ADDRESS), CChainParams::STAKING_ADDRESS); } -UniValue getnewshieldedaddress(const JSONRPCRequest& request) +UniValue getnewshieldaddress(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() > 1) throw std::runtime_error( - "getnewshieldedaddress\n" - "\nReturns a new shielded address for receiving payments.\n" + "getnewshieldaddress\n" + "\nReturns a new shield address for receiving payments.\n" "\nArguments:\n" "\nResult:\n" - "\"address\" (string) The new shielded address.\n" + "\"address\" (string) The new shield address.\n" "\nExamples:\n" - + HelpExampleCli("getnewshieldedaddress", "") - + HelpExampleRpc("getnewshieldedaddress", "") + + HelpExampleCli("getnewshieldaddress", "") + + HelpExampleRpc("getnewshieldaddress", "") ); EnsureWallet(); @@ -524,21 +524,21 @@ UniValue getnewshieldedaddress(const JSONRPCRequest& request) return KeyIO::EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey()); } -UniValue listshieldedunspent(const JSONRPCRequest& request) +UniValue listshieldunspent(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() > 4) throw std::runtime_error( - "listshieldedunspent ( minconf maxconf includeWatchonly [\"shield_addr\",...] )\n" - "\nReturns array of unspent shielded notes with between minconf and maxconf (inclusive) confirmations.\n" + "listshieldunspent ( minconf maxconf includeWatchonly [\"shield_addr\",...] )\n" + "\nReturns array of unspent shield notes with between minconf and maxconf (inclusive) confirmations.\n" "Optionally filter to only include notes sent to specified addresses.\n" "When minconf is 0, unspent notes with zero confirmations are returned, even though they are not immediately spendable.\n" "\nArguments:\n" "1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n" "2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n" "3. includeWatchonly (bool, optional, default=false) Also include watchonly addresses (see 'importsaplingviewingkey')\n" - "4. \"addresses\" (string) A json array of shielded addrs to filter on. Duplicate addresses not allowed.\n" + "4. \"addresses\" (string) A json array of shield addrs to filter on. Duplicate addresses not allowed.\n" " [\n" - " \"address\" (string) shielded addr\n" + " \"address\" (string) shield addr\n" " ,...\n" " ]\n" "\nResult:\n" @@ -548,7 +548,7 @@ UniValue listshieldedunspent(const JSONRPCRequest& request) " \"outindex\" (sapling) : n, (numeric) the output index\n" " \"confirmations\" : n, (numeric) the number of confirmations\n" " \"spendable\" : true|false, (boolean) true if note can be spent by wallet, false if address is watchonly\n" - " \"address\" : \"address\", (string) the shielded address\n" + " \"address\" : \"address\", (string) the shield address\n" " \"amount\": xxxxx, (numeric) the amount of value in the note\n" " \"memo\": xxxxx, (string) hexademical string representation of memo field\n" " \"change\": true|false, (boolean) true if the address that received the note is also one of the sending addresses\n" @@ -558,9 +558,9 @@ UniValue listshieldedunspent(const JSONRPCRequest& request) "]\n" "\nExamples\n" - + HelpExampleCli("listshieldedunspent", "") - + HelpExampleCli("listshieldedunspent", "6 9999999 false \"[\\\"ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh\\\",\\\"ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh\\\"]\"") - + HelpExampleRpc("listshieldedunspent", "6 9999999 false \"[\\\"ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh\\\",\\\"ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh\\\"]\"") + + HelpExampleCli("listshieldunspent", "") + + HelpExampleCli("listshieldunspent", "6 9999999 false \"[\\\"ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh\\\",\\\"ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh\\\"]\"") + + HelpExampleRpc("listshieldunspent", "6 9999999 false \"[\\\"ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh\\\",\\\"ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh\\\"]\"") ); EnsureWallet(); @@ -582,7 +582,7 @@ UniValue listshieldedunspent(const JSONRPCRequest& request) LOCK2(cs_main, pwalletMain->cs_wallet); - // User has supplied shielded addrs to filter on + // User has supplied shield addrs to filter on if (request.params.size() > 3) { UniValue addresses = request.params[3].get_array(); if (addresses.size()==0) @@ -614,7 +614,7 @@ UniValue listshieldedunspent(const JSONRPCRequest& request) setAddress.insert(address); } } else { - // User did not provide shielded addrs, so use default i.e. all addresses + // User did not provide shield addrs, so use default i.e. all addresses std::set saplingzaddrs = {}; pwalletMain->GetSaplingPaymentAddresses(saplingzaddrs); shieldAddrs.insert(saplingzaddrs.begin(), saplingzaddrs.end()); @@ -802,22 +802,22 @@ UniValue liststakingaddresses(const JSONRPCRequest& request) return ListaddressesForPurpose(AddressBook::AddressBookPurpose::COLD_STAKING); } -UniValue listshieldedaddresses(const JSONRPCRequest& request) +UniValue listshieldaddresses(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() > 1) throw std::runtime_error( - "listshieldedaddresses ( includeWatchonly )\n" - "\nReturns the list of shielded addresses belonging to the wallet.\n" + "listshieldaddresses ( includeWatchonly )\n" + "\nReturns the list of shield addresses belonging to the wallet.\n" "\nArguments:\n" "1. includeWatchonly (bool, optional, default=false) Also include watchonly addresses (see 'importviewingkey')\n" "\nResult:\n" "[ (json array of string)\n" - " \"addr\" (string) a shielded address belonging to the wallet\n" + " \"addr\" (string) a shield address belonging to the wallet\n" " ,...\n" "]\n" "\nExamples:\n" - + HelpExampleCli("listshieldedaddresses", "") - + HelpExampleRpc("listshieldedaddresses", "") + + HelpExampleCli("listshieldaddresses", "") + + HelpExampleRpc("listshieldaddresses", "") ); EnsureWallet(); @@ -941,15 +941,15 @@ void SendMoney(const CTxDestination& address, CAmount nValue, CWalletTx& wtxNew) static SaplingOperation CreateShieldedTransaction(const JSONRPCRequest& request); /* - * redirect sendtoaddress/sendmany inputs to shieldedsendmany implementation (CreateShieldedTransaction) + * redirect sendtoaddress/sendmany inputs to shieldsendmany implementation (CreateShieldedTransaction) */ -static UniValue ShieldedSendManyTo(const UniValue& sendTo, +static UniValue ShieldSendManyTo(const UniValue& sendTo, const std::string& commentStr, const std::string& toStr, int nMinDepth, bool fIncludeDelegated) { - // convert params to 'shieldedsendmany' format + // convert params to 'shieldsendmany' format JSONRPCRequest req; req.params = UniValue(UniValue::VARR); if (!fIncludeDelegated) { @@ -1025,7 +1025,7 @@ UniValue sendtoaddress(const JSONRPCRequest& request) if (isShielded) { UniValue sendTo(UniValue::VOBJ); sendTo.pushKV(addrStr, request.params[1]); - return ShieldedSendManyTo(sendTo, commentStr, toStr, 1, false); + return ShieldSendManyTo(sendTo, commentStr, toStr, 1, false); } const CTxDestination& address = *Standard::GetTransparentDestination(destination); @@ -1137,7 +1137,7 @@ UniValue CreateColdStakeDelegation(const UniValue& params, CWalletTx& wtxNew, CR throw JSONRPCError(RPC_WALLET_ERROR, strError); } } else { - // Delegate shielded coins + // Delegate shield coins const Consensus::Params& consensus = Params().GetConsensus(); // Check network status int nextBlockHeight = chainActive.Height() + 1; @@ -1164,7 +1164,7 @@ UniValue delegatestake(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() < 2 || request.params.size() > 7) throw std::runtime_error( - "delegatestake \"stakingaddress\" amount ( \"owneraddress\" fExternalOwner fUseDelegated fForceNotEnabled )\n" + "delegatestake \"stakingaddress\" amount ( \"owneraddress\" fExternalOwner fUseDelegated fFromShield fForceNotEnabled )\n" "\nDelegate an amount to a given address for cold staking. The amount is a real and is rounded to the nearest 0.00000001\n" + HelpRequiringPassphrase() + "\n" @@ -1176,7 +1176,7 @@ UniValue delegatestake(const JSONRPCRequest& request) "4. \"fExternalOwner\" (boolean, optional, default = false) use the provided 'owneraddress' anyway, even if not present in this wallet.\n" " WARNING: The owner of the keys to 'owneraddress' will be the only one allowed to spend these coins.\n" "5. \"fUseDelegated\" (boolean, optional, default = false) include already delegated inputs if needed.\n" - "6. \"fFromShielded\" (boolean, optional, default = false) delegate shielded funds.\n" + "6. \"fFromShield\" (boolean, optional, default = false) delegate shield funds.\n" "7. \"fForceNotEnabled\" (boolean, optional, default = false) ONLY FOR TESTING: force the creation even if SPORK 17 is disabled.\n" "\nResult:\n" @@ -1209,7 +1209,7 @@ UniValue rawdelegatestake(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() < 2 || request.params.size() > 7) throw std::runtime_error( - "rawdelegatestake \"stakingaddress\" amount ( \"owneraddress\" fExternalOwner fUseDelegated )\n" + "rawdelegatestake \"stakingaddress\" amount ( \"owneraddress\" fExternalOwner fUseDelegated fFromShield )\n" "\nDelegate an amount to a given address for cold staking. The amount is a real and is rounded to the nearest 0.00000001\n" "\nDelegate transaction is returned as json object." + HelpRequiringPassphrase() + "\n" @@ -1222,7 +1222,7 @@ UniValue rawdelegatestake(const JSONRPCRequest& request) "4. \"fExternalOwner\" (boolean, optional, default = false) use the provided 'owneraddress' anyway, even if not present in this wallet.\n" " WARNING: The owner of the keys to 'owneraddress' will be the only one allowed to spend these coins.\n" "5. \"fUseDelegated\" (boolean, optional, default = false) include already delegated inputs if needed.\n" - "6. \"fFromShielded\" (boolean, optional, default = false) delegate shielded funds.\n" + "6. \"fFromShield\" (boolean, optional, default = false) delegate shield funds.\n" "7. \"fForceNotEnabled\" (boolean, optional, default = false) ONLY FOR TESTING: force the creation even if SPORK 17 is disabled (for tests).\n" "\nResult:\n" @@ -1295,16 +1295,16 @@ CAmount getBalanceShieldedAddr(Optional& filter return balance; } -UniValue getshieldedbalance(const JSONRPCRequest& request) +UniValue getshieldbalance(const JSONRPCRequest& request) { if (!pwalletMain) return NullUniValue; if (request.fHelp || request.params.size() > 3) throw std::runtime_error( - "getshieldedbalance \"address\" ( minconf includeWatchonly )\n" - "\nReturn the total shielded value of funds stored in the node's wallet or if an address was given," - "\nreturns the balance of the shielded addr belonging to the node's wallet.\n" + "getshieldbalance \"address\" ( minconf includeWatchonly )\n" + "\nReturn the total shield value of funds stored in the node's wallet or if an address was given," + "\nreturns the balance of the shield addr belonging to the node's wallet.\n" "\nCAUTION: If the wallet contains any addresses for which it only has incoming viewing keys," "\nthe returned private balance may be larger than the actual balance, because spends cannot" "\nbe detected with incoming viewing keys.\n" @@ -1313,15 +1313,15 @@ UniValue getshieldedbalance(const JSONRPCRequest& request) "2. minconf (numeric, optional, default=1) Only include private and transparent transactions confirmed at least this many times.\n" "3. includeWatchonly (bool, optional, default=false) Also include balance in watchonly addresses (see 'importaddress' and 'importsaplingviewingkey')\n" "\nResult:\n" - "amount (numeric) the total balance of shielded funds (in Sapling addresses)\n" + "amount (numeric) the total balance of shield funds (in Sapling addresses)\n" "\nExamples:\n" "\nThe total amount in the wallet\n" - + HelpExampleCli("getshieldedbalance", "") - + HelpExampleCli("getshieldedbalance", "ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh") + + + HelpExampleCli("getshieldbalance", "") + + HelpExampleCli("getshieldbalance", "ptestsapling1h0w73csah2aq0a32h42kr7tq4htlt5wfn4ejxfnm56f6ehjvek7k4e244g6v8v3pgylmz5ea8jh") + "\nThe total amount in the wallet at least 5 blocks confirmed\n" - + HelpExampleCli("getshieldedbalance", "\"*\" \"5\"") + + + HelpExampleCli("getshieldbalance", "\"*\" \"5\"") + "\nAs a json rpc call\n" - + HelpExampleRpc("getshieldedbalance", "\"*\" \"5\"") + + HelpExampleRpc("getshieldbalance", "\"*\" \"5\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -1332,7 +1332,7 @@ UniValue getshieldedbalance(const JSONRPCRequest& request) if (addressStr.empty() || addressStr != "*") { address = KeyIO::DecodeSaplingPaymentAddress(addressStr); if (!address) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid shielded address"); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid shield address"); } } } @@ -1347,12 +1347,12 @@ UniValue getshieldedbalance(const JSONRPCRequest& request) return ValueFromAmount(nBalance); } -UniValue viewshieldedtransaction(const JSONRPCRequest& request) +UniValue viewshieldtransaction(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 1) throw std::runtime_error( - "viewshieldedtransaction \"txid\"\n" - "\nGet detailed shielded information about in-wallet transaction \n" + "viewshieldtransaction \"txid\"\n" + "\nGet detailed shield information about in-wallet transaction \n" + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"txid\" (string, required) The transaction id\n" @@ -1386,8 +1386,8 @@ UniValue viewshieldedtransaction(const JSONRPCRequest& request) "}\n" "\nExamples:\n" - + HelpExampleCli("viewshieldedtransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") - + HelpExampleRpc("viewshieldedtransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleCli("viewshieldtransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + + HelpExampleRpc("viewshieldtransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") ); if (!pwalletMain->HasSaplingSPKM()) { @@ -1406,7 +1406,7 @@ UniValue viewshieldedtransaction(const JSONRPCRequest& request) const CWalletTx& wtx = pwalletMain->mapWallet[hash]; if (!wtx.IsShieldedTx()) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid transaction, no shielded data available"); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid transaction, no shield data available"); } entry.pushKV("txid", hash.GetHex()); @@ -1526,7 +1526,7 @@ static SaplingOperation CreateShieldedTransaction(const JSONRPCRequest& request) SaplingOperation operation(txBuilder); // Param 0: source of funds. Can either be a valid address, sapling address, - // or the string "from_transparent"|"from_trans_cold"|"from_shielded" + // or the string "from_transparent"|"from_trans_cold"|"from_shield" bool fromSapling = false; std::string sendFromStr = request.params[0].get_str(); if (sendFromStr == "from_transparent") { @@ -1535,8 +1535,8 @@ static SaplingOperation CreateShieldedTransaction(const JSONRPCRequest& request) } else if (sendFromStr == "from_trans_cold") { // send from any transparent address + delegations operation.setSelectTransparentCoins(true, true); - } else if (sendFromStr == "from_shielded") { - // send from any shielded address + } else if (sendFromStr == "from_shield") { + // send from any shield address operation.setSelectShieldedCoins(true); fromSapling = true; } else { @@ -1544,13 +1544,13 @@ static SaplingOperation CreateShieldedTransaction(const JSONRPCRequest& request) if (!IsValidDestination(fromTAddressDest)) { auto res = KeyIO::DecodePaymentAddress(sendFromStr); if (!IsValidPaymentAddress(res)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address, should be a taddr or shielded addr."); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address, should be a taddr or shield addr."); } libzcash::SaplingPaymentAddress fromShieldedAddress = *boost::get(&res); if (!pwalletMain->HaveSpendingKeyForPaymentAddress(fromShieldedAddress)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, shielded addr spending key not found."); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, shield addr spending key not found."); } - // send from user-supplied shielded address + // send from user-supplied shield address operation.setFromAddress(fromShieldedAddress); fromSapling = true; } else { @@ -1604,7 +1604,7 @@ static SaplingOperation CreateShieldedTransaction(const JSONRPCRequest& request) if (!memoValue.isNull()) { memo = memoValue.get_str(); if (!saddr) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo cannot be used with a taddr. It can only be used with a shielded addr."); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo cannot be used with a taddr. It can only be used with a shield addr."); } if (memo.length() > ZC_MEMO_SIZE*2) { throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", ZC_MEMO_SIZE )); @@ -1658,7 +1658,7 @@ static SaplingOperation CreateShieldedTransaction(const JSONRPCRequest& request) } if (fromSapling && nMinDepth == 0) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Minconf cannot be zero when sending from shielded addr"); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Minconf cannot be zero when sending from shield addr"); } if (nMinDepth < 0) { @@ -1673,37 +1673,37 @@ static SaplingOperation CreateShieldedTransaction(const JSONRPCRequest& request) return operation; } -UniValue shieldedsendmany(const JSONRPCRequest& request) +UniValue shieldsendmany(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() < 2 || request.params.size() > 4) throw std::runtime_error( - "shieldedsendmany \"fromaddress\" [{\"address\":... ,\"amount\":...},...] ( minconf ) ( fee )\n" + "shieldsendmany \"fromaddress\" [{\"address\":... ,\"amount\":...},...] ( minconf fee )\n" "\nSend to many recipients. Amounts are decimal numbers with at most 8 digits of precision." - "\nChange generated from a transparent addr flows to a new transparent addr address, while change generated from a shielded addr returns to itself." - "\nWhen sending coinbase UTXOs to a shielded addr, change is not allowed. The entire value of the UTXO(s) must be consumed." + "\nChange generated from a transparent addr flows to a new transparent addr address, while change generated from a shield addr returns to itself." + "\nWhen sending coinbase UTXOs to a shield addr, change is not allowed. The entire value of the UTXO(s) must be consumed." + HelpRequiringPassphrase() + "\n" "\nArguments:\n" - "1. \"fromaddress\" (string, required) The transparent addr or shielded addr to send the funds from.\n" - " It can also be the string \"from_transparent\"|\"from_shielded\" to send the funds\n" - " from any transparent|shielded address available.\n" + "1. \"fromaddress\" (string, required) The transparent addr or shield addr to send the funds from.\n" + " It can also be the string \"from_transparent\"|\"from_shield\" to send the funds\n" + " from any transparent|shield address available.\n" " Additionally, it can be the string \"from_trans_cold\" to select transparent funds,\n" " possibly including delegated coins, if needed.\n" "2. \"amounts\" (array, required) An array of json objects representing the amounts to send.\n" " [{\n" - " \"address\":address (string, required) The address is a transparent addr or shielded addr\n" + " \"address\":address (string, required) The address is a transparent addr or shield addr\n" " \"amount\":amount (numeric, required) The numeric amount in " + "PIV" + " is the value\n" - " \"memo\":memo (string, optional) If the address is a shielded addr, message string of max 512 bytes\n" + " \"memo\":memo (string, optional) If the address is a shield addr, message string of max 512 bytes\n" " }, ... ]\n" "3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times.\n" "4. fee (numeric, optional), The fee amount to attach to this transaction.\n" - " If not specified, the wallet will try to compute the minimum possible fee for a shielded TX,\n" + " If not specified, the wallet will try to compute the minimum possible fee for a shield TX,\n" " based on the expected transaction size and the current value of -minRelayTxFee.\n" "\nResult:\n" "\"id\" (string) transaction hash in the network\n" "\nExamples:\n" - + HelpExampleCli("shieldedsendmany", + + HelpExampleCli("shieldsendmany", "\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" '[{\"address\": \"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\" ,\"amount\": 5.0}]'") - + HelpExampleRpc("shieldedsendmany", + + HelpExampleRpc("shieldsendmany", "\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\", [{\"address\": \"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\" ,\"amount\": 5.0}]") ); @@ -1715,38 +1715,38 @@ UniValue shieldedsendmany(const JSONRPCRequest& request) return txHash; } -UniValue rawshieldedsendmany(const JSONRPCRequest& request) +UniValue rawshieldsendmany(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() < 2 || request.params.size() > 4) throw std::runtime_error( - "rawshieldedsendmany \"fromaddress\" [{\"address\":... ,\"amount\":...},...] ( minconf ) ( fee )\n" + "rawshieldsendmany \"fromaddress\" [{\"address\":... ,\"amount\":...},...] ( minconf fee )\n" "\nCreates a transaction sending to many recipients (without committing it), and returns the hex string." "\nAmounts are decimal numbers with at most 8 digits of precision." - "\nChange generated from a transparent addr flows to a new transparent addr address, while change generated from a shielded addr returns to itself." - "\nWhen sending coinbase UTXOs to a shielded addr, change is not allowed. The entire value of the UTXO(s) must be consumed." + "\nChange generated from a transparent addr flows to a new transparent addr address, while change generated from a shield addr returns to itself." + "\nWhen sending coinbase UTXOs to a shield addr, change is not allowed. The entire value of the UTXO(s) must be consumed." + HelpRequiringPassphrase() + "\n" "\nArguments:\n" - "1. \"fromaddress\" (string, required) The transparent addr or shielded addr to send the funds from.\n" - " It can also be the string \"from_transparent\"|\"from_shielded\" to send the funds\n" - " from any transparent|shielded address available.\n" + "1. \"fromaddress\" (string, required) The transparent addr or shield addr to send the funds from.\n" + " It can also be the string \"from_transparent\"|\"from_shield\" to send the funds\n" + " from any transparent|shield address available.\n" " Additionally, it can be the string \"from_trans_cold\" to select transparent funds,\n" " possibly including delegated coins, if needed.\n" "2. \"amounts\" (array, required) An array of json objects representing the amounts to send.\n" " [{\n" - " \"address\":address (string, required) The address is a transparent addr or shielded addr\n" + " \"address\":address (string, required) The address is a transparent addr or shield addr\n" " \"amount\":amount (numeric, required) The numeric amount in " + "PIV" + " is the value\n" - " \"memo\":memo (string, optional) If the address is a shielded addr, message string of max 512 bytes\n" + " \"memo\":memo (string, optional) If the address is a shield addr, message string of max 512 bytes\n" " }, ... ]\n" "3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times.\n" "4. fee (numeric, optional), The fee amount to attach to this transaction.\n" - " If not specified, the wallet will try to compute the minimum possible fee for a shielded TX,\n" + " If not specified, the wallet will try to compute the minimum possible fee for a shield TX,\n" " based on the expected transaction size and the current value of -minRelayTxFee.\n" "\nResult:\n" "{tx_json} (json object) decoded transaction\n" "\nExamples:\n" - + HelpExampleCli("rawshieldedsendmany", + + HelpExampleCli("rawshieldsendmany", "\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" '[{\"address\": \"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\" ,\"amount\": 5.0}]'") - + HelpExampleRpc("rawshieldedsendmany", + + HelpExampleRpc("rawshieldsendmany", "\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\", [{\"address\": \"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\" ,\"amount\": 5.0}]") ); @@ -1970,7 +1970,7 @@ UniValue getbalance(const JSONRPCRequest& request) { if (request.fHelp || (request.params.size() > 4 )) throw std::runtime_error( - "getbalance ( minconf includeWatchonly includeDelegated )\n" + "getbalance ( minconf includeWatchonly includeDelegated includeShield )\n" "\nReturns the server's total available balance.\n" "The available balance is what the wallet considers currently spendable, and is\n" "thus affected by options which limit spendability such as -spendzeroconfchange.\n" @@ -1979,7 +1979,7 @@ UniValue getbalance(const JSONRPCRequest& request) "1. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "2. includeWatchonly (bool, optional, default=false) Also include balance in watchonly addresses (see 'importaddress')\n" "3. includeDelegated (bool, optional, default=true) Also include balance delegated to cold stakers\n" - "4. includeShielded (bool, optional, default=true) Also include shielded balance\n" + "4. includeShield (bool, optional, default=true) Also include shield balance\n" "\nResult:\n" "amount (numeric) The total amount in PIV received for this wallet.\n" @@ -2134,14 +2134,14 @@ static UniValue legacy_sendmany(const UniValue& sendTo, int nMinDepth, std::stri /* * This function uses [legacy_sendmany] in the background. - * If any recipient is a shielded address, instead it uses [shieldedsendmany "from_transparent"]. + * If any recipient is a shield address, instead it uses [shieldsendmany "from_transparent"]. */ UniValue sendmany(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() < 2 || request.params.size() > 5) throw std::runtime_error( "sendmany \"\" {\"address\":amount,...} ( minconf \"comment\" includeDelegated )\n" - "\nSend to multiple destinations. Recipients are transparent or shielded PIVX addresses.\n" + "\nSend to multiple destinations. Recipients are transparent or shield PIVX addresses.\n" "\nAmounts are double-precision floating point numbers.\n" + HelpRequiringPassphrase() + "\n" @@ -2149,7 +2149,7 @@ UniValue sendmany(const JSONRPCRequest& request) "1. \"dummy\" (string, required) Must be set to \"\" for backwards compatibility.\n" "2. \"amounts\" (string, required) A json object with addresses and amounts\n" " {\n" - " \"address\":amount (numeric) The pivx address (either transparent or shielded) is the key,\n" + " \"address\":amount (numeric) The pivx address (either transparent or shield) is the key,\n" " the numeric amount in PIV is the value\n" " ,...\n" " }\n" @@ -2166,7 +2166,7 @@ UniValue sendmany(const JSONRPCRequest& request) HelpExampleCli("sendmany", "\"\" \"{\\\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\\\":0.01,\\\"DAD3Y6ivr8nPQLT1NEPX84DxGCw9jz9Jvg\\\":0.02}\"") + "\nSend two amounts to two different addresses setting the confirmation and comment:\n" + HelpExampleCli("sendmany", "\"\" \"{\\\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\\\":0.01,\\\"DAD3Y6ivr8nPQLT1NEPX84DxGCw9jz9Jvg\\\":0.02}\" 6 \"testing\"") + - "\nSend to shielded address:\n" + + "\nSend to shield address:\n" + HelpExampleCli("sendmany", "\"\" \"{\\\"ps1u87kylcmn28yclnx2uy0psnvuhs2xn608ukm6n2nshrpg2nzyu3n62ls8j77m9cgp40dx40evej\\\":10}\"") + "\nAs a json rpc call\n" + HelpExampleRpc("sendmany", "\"\", \"{\\\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\\\":0.01,\\\"DAD3Y6ivr8nPQLT1NEPX84DxGCw9jz9Jvg\\\":0.02}\", 6, \"testing\"") @@ -2182,7 +2182,7 @@ UniValue sendmany(const JSONRPCRequest& request) request.params[3].get_str() : ""; const bool fIncludeDelegated = (request.params.size() > 5 && request.params[5].get_bool()); - // Check if any recipient address is shielded + // Check if any recipient address is shield bool fShieldSend = false; for (const std::string& key : sendTo.getKeys()) { bool isStaking = false, isShielded = false; @@ -2194,7 +2194,7 @@ UniValue sendmany(const JSONRPCRequest& request) } if (fShieldSend) { - return ShieldedSendManyTo(sendTo, comment, "", nMinDepth, fIncludeDelegated); + return ShieldSendManyTo(sendTo, comment, "", nMinDepth, fIncludeDelegated); } // All recipients are transparent: use Legacy sendmany t->t @@ -2435,12 +2435,12 @@ UniValue listreceivedbyaddress(const JSONRPCRequest& request) return ListReceived(request.params, false); } -UniValue listreceivedbyshieldedaddress(const JSONRPCRequest& request) +UniValue listreceivedbyshieldaddress(const JSONRPCRequest& request) { if (request.fHelp || request.params.size()==0 || request.params.size() >2) throw std::runtime_error( - "listreceivedbyshieldedaddress \"address\" ( minconf )\n" - "\nReturn a list of amounts received by a shielded addr belonging to the node's wallet.\n" + "listreceivedbyshieldaddress \"address\" ( minconf )\n" + "\nReturn a list of amounts received by a shield addr belonging to the node's wallet.\n" "\nArguments:\n" "1. \"address\" (string) The private address.\n" "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" @@ -2457,8 +2457,8 @@ UniValue listreceivedbyshieldedaddress(const JSONRPCRequest& request) " \"change\": true|false, (boolean) true if the address that received the note is also one of the sending addresses\n" "}\n" "\nExamples:\n" - + HelpExampleCli("listreceivedbyshieldedaddress", "\"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\"") - + HelpExampleRpc("listreceivedbyshieldedaddress", "\"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\"") + + HelpExampleCli("listreceivedbyshieldaddress", "\"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\"") + + HelpExampleRpc("listreceivedbyshieldaddress", "\"ps1ra969yfhvhp73rw5ak2xvtcm9fkuqsnmad7qln79mphhdrst3lwu9vvv03yuyqlh42p42st47qd\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -2478,12 +2478,12 @@ UniValue listreceivedbyshieldedaddress(const JSONRPCRequest& request) if (!zaddr) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addr."); } - libzcash::SaplingPaymentAddress shieldedAddr = *zaddr; + libzcash::SaplingPaymentAddress shieldAddr = *zaddr; auto sspkm = pwalletMain->GetSaplingScriptPubKeyMan(); // Visitor to support Sapling addrs - if (!sspkm->PaymentAddressBelongsToWallet(shieldedAddr)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, shielded addr spending key or viewing key not found."); + if (!sspkm->PaymentAddressBelongsToWallet(shieldAddr)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, shield addr spending key or viewing key not found."); } UniValue result(UniValue::VARR); @@ -2491,7 +2491,7 @@ UniValue listreceivedbyshieldedaddress(const JSONRPCRequest& request) sspkm->GetFilteredNotes(saplingEntries, zaddr, nMinDepth, false, false); std::set> nullifierSet; - bool hasSpendingKey = pwalletMain->HaveSpendingKeyForPaymentAddress(shieldedAddr); + bool hasSpendingKey = pwalletMain->HaveSpendingKeyForPaymentAddress(shieldAddr); if (hasSpendingKey) { nullifierSet = sspkm->GetNullifiersForAddresses({*zaddr}); } @@ -4148,18 +4148,18 @@ static const CRPCCommand commands[] = { "wallet", "multisend", &multisend, false }, /** Sapling functions */ - { "wallet", "getnewshieldedaddress", &getnewshieldedaddress, true }, - { "wallet", "listshieldedaddresses", &listshieldedaddresses, false }, + { "wallet", "getnewshieldaddress", &getnewshieldaddress, true }, + { "wallet", "listshieldaddresses", &listshieldaddresses, false }, { "wallet", "exportsaplingkey", &exportsaplingkey, true }, { "wallet", "importsaplingkey", &importsaplingkey, true }, { "wallet", "importsaplingviewingkey", &importsaplingviewingkey, true }, { "wallet", "exportsaplingviewingkey", &exportsaplingviewingkey, true }, - { "wallet", "getshieldedbalance", &getshieldedbalance, false }, - { "wallet", "listshieldedunspent", &listshieldedunspent, false }, - { "wallet", "rawshieldedsendmany", &rawshieldedsendmany, false }, - { "wallet", "shieldedsendmany", &shieldedsendmany, false }, - { "wallet", "listreceivedbyshieldedaddress", &listreceivedbyshieldedaddress, false }, - { "wallet", "viewshieldedtransaction", &viewshieldedtransaction, false }, + { "wallet", "getshieldbalance", &getshieldbalance, false }, + { "wallet", "listshieldunspent", &listshieldunspent, false }, + { "wallet", "rawshieldsendmany", &rawshieldsendmany, false }, + { "wallet", "shieldsendmany", &shieldsendmany, false }, + { "wallet", "listreceivedbyshieldaddress", &listreceivedbyshieldaddress, false }, + { "wallet", "viewshieldtransaction", &viewshieldtransaction, false }, { "wallet", "getsaplingnotescount", &getsaplingnotescount, false }, /** Label functions (to replace non-balance account functions) */ diff --git a/test/functional/mining_pos_coldStaking.py b/test/functional/mining_pos_coldStaking.py index 4d4fb341bfaef..edd459037e4d5 100755 --- a/test/functional/mining_pos_coldStaking.py +++ b/test/functional/mining_pos_coldStaking.py @@ -123,13 +123,13 @@ def run_test(self): assert_equal(self.nodes[1].getstakingstatus()["stakeablecoins"], 0) # create shielded balance for node 0 self.log.info("Shielding some coins for node0...") - self.nodes[0].shieldedsendmany("from_transparent", [{"address": self.nodes[0].getnewshieldedaddress(), + self.nodes[0].shieldsendmany("from_transparent", [{"address": self.nodes[0].getnewshieldaddress(), "amount": Decimal('250.00')}], 1) self.sync_all() for i in range(6): self.mocktime = self.generate_pow(0, self.mocktime) sync_blocks(self.nodes) - assert_equal(self.nodes[0].getshieldedbalance(), 250) + assert_equal(self.nodes[0].getshieldbalance(), 250) # 3) nodes[0] generates a owner address # nodes[1] generates a cold-staking address. @@ -191,7 +191,7 @@ def run_test(self): assert (res != None and res["txid"] != None and res["txid"] != "") assert_equal(res["owner_address"], owner_address) assert_equal(res["staker_address"], staker_address) - fee = self.nodes[0].viewshieldedtransaction(res["txid"])['fee'] + fee = self.nodes[0].viewshieldtransaction(res["txid"])['fee'] # sync and mine 2 blocks sync_mempools(self.nodes) self.mocktime = self.generate_pos(2, self.mocktime) @@ -202,7 +202,7 @@ def run_test(self): self.expected_immature_balance = 0 self.checkBalances() # also shielded balance of node 0 (250 - 249 - fee) - assert_equal(self.nodes[0].getshieldedbalance(), round(Decimal(1)-Decimal(fee), 8)) + assert_equal(self.nodes[0].getshieldbalance(), round(Decimal(1)-Decimal(fee), 8)) # 6) check that the owner (nodes[0]) can spend the coins. # ------------------------------------------------------- diff --git a/test/functional/sapling_changeaddresses.py b/test/functional/sapling_changeaddresses.py index 8c05e43cac014..4f9d3db6966dd 100755 --- a/test/functional/sapling_changeaddresses.py +++ b/test/functional/sapling_changeaddresses.py @@ -22,9 +22,9 @@ def run_test(self): self.nodes[0].generate(110) # Obtain some transparent funds - midAddr = self.nodes[0].getnewshieldedaddress() + midAddr = self.nodes[0].getnewshieldaddress() # Shield almost all the balance - txid = self.nodes[0].shieldedsendmany(get_coinstake_address(self.nodes[0]), [{"address": midAddr, "amount": Decimal(2400)}]) + txid = self.nodes[0].shieldsendmany(get_coinstake_address(self.nodes[0]), [{"address": midAddr, "amount": Decimal(2400)}]) self.sync_all() self.nodes[1].generate(1) @@ -32,7 +32,7 @@ def run_test(self): taddrSource = self.nodes[0].getnewaddress() for _ in range(6): recipients = [{"address": taddrSource, "amount": Decimal('3')}] - txid = self.nodes[0].shieldedsendmany(midAddr, recipients, 1) + txid = self.nodes[0].shieldsendmany(midAddr, recipients, 1) self.sync_all() self.nodes[1].generate(1) self.sync_all() @@ -41,10 +41,10 @@ def check_change_taddr_reuse(target, isTargetShielded): recipients = [{"address": target, "amount": Decimal('1')}] # Send funds to recipient address twice - txid1 = self.nodes[0].shieldedsendmany(taddrSource, recipients, 1) + txid1 = self.nodes[0].shieldsendmany(taddrSource, recipients, 1) self.nodes[1].generate(1) self.sync_all() - txid2 = self.nodes[0].shieldedsendmany(taddrSource, recipients, 1) + txid2 = self.nodes[0].shieldsendmany(taddrSource, recipients, 1) self.nodes[1].generate(1) self.sync_all() @@ -63,13 +63,13 @@ def check_change_taddr_reuse(target, isTargetShielded): assert(tx1OutAddrs != tx2OutAddrs) taddr = self.nodes[0].getnewaddress() - saplingAddr = self.nodes[0].getnewshieldedaddress() + saplingAddr = self.nodes[0].getnewshieldaddress() print() - print('Checking shieldedsendmany(taddr->Sapling)') + print('Checking shieldsendmany(taddr->Sapling)') check_change_taddr_reuse(saplingAddr, True) print() - print('Checking shieldedsendmany(taddr->taddr)') + print('Checking shieldsendmany(taddr->taddr)') check_change_taddr_reuse(taddr, False) if __name__ == '__main__': diff --git a/test/functional/sapling_fillblock.py b/test/functional/sapling_fillblock.py index 0a1d8e504ab10..9dc69af05eaaf 100755 --- a/test/functional/sapling_fillblock.py +++ b/test/functional/sapling_fillblock.py @@ -74,7 +74,7 @@ def mine_and_checkblock(self, miner, alice): def send_shielded(self, node, n_txes, from_address, shield_to): txids = [] for i in range(n_txes): - txids.append(node.shieldedsendmany(from_address, shield_to)) + txids.append(node.shieldsendmany(from_address, shield_to)) if (i + 1) % 200 == 0: self.log.info("...%d Transactions created..." % (i + 1)) return txids @@ -104,7 +104,7 @@ def run_test(self): # Now alice shields the new utxos individually (fixed 0.2 PIV fee --> ~2.3 PIV notes) self.log.info("Shielding utxos...") - alice_z_addr = alice.getnewshieldedaddress() + alice_z_addr = alice.getnewshieldaddress() shield_to = [{"address": alice_z_addr, "amount": new_utxos[0]["amount"] - Decimal("0.2")}] txids = self.send_shielded(alice, UTXOS_TO_SHIELD, "from_transparent", shield_to) diff --git a/test/functional/sapling_key_import_export.py b/test/functional/sapling_key_import_export.py index 4d220120d78ff..1f90b5bdd0b82 100755 --- a/test/functional/sapling_key_import_export.py +++ b/test/functional/sapling_key_import_export.py @@ -22,7 +22,7 @@ def run_test(self): # the sender loses 'amount' plus fee; to_addr receives exactly 'amount' def shielded_send(from_node, from_addr, to_addr, amount): - txid = from_node.shieldedsendmany(from_addr, + txid = from_node.shieldsendmany(from_addr, [{"address": to_addr, "amount": Decimal(amount)}], 1) self.sync_all() miner.generate(1) @@ -31,7 +31,7 @@ def shielded_send(from_node, from_addr, to_addr, amount): def verify_utxos(node, amts, shield_addr): amts.sort(reverse=True) - txs = node.listreceivedbyshieldedaddress(shield_addr) + txs = node.listreceivedbyshieldaddress(shield_addr) txs.sort(key=lambda x: x["amount"], reverse=True) try: @@ -46,7 +46,7 @@ def verify_utxos(node, amts, shield_addr): raise def get_private_balance(node): - return node.getshieldedbalance() + return node.getshieldbalance() # Seed Alice with some funds alice.generate(10) @@ -56,11 +56,11 @@ def get_private_balance(node): fromAddress = alice.listunspent()[0]['address'] amountTo = 10 * 250 - 1 # Shield Alice's coinbase funds to her shield_addr - alice_addr = alice.getnewshieldedaddress() + alice_addr = alice.getnewshieldaddress() txid = shielded_send(alice, fromAddress, alice_addr, amountTo) # Now get a pristine address for receiving transfers: - bob_addr = bob.getnewshieldedaddress() + bob_addr = bob.getnewshieldaddress() verify_utxos(bob, [], bob_addr) # TODO: Verify that charlie doesn't have funds in addr # verify_utxos(charlie, []) @@ -117,18 +117,18 @@ def get_private_balance(node): for amount in amounts[:2]: print("Sending amount from bob to alice: ", amount) txid = shielded_send(bob, bob_addr, alice_addr, amount) - bob_fee += Decimal(bob.viewshieldedtransaction(txid)['fee']) + bob_fee += Decimal(bob.viewshieldtransaction(txid)['fee']) bob_balance = sum(amounts[2:]) - bob_fee - assert_equal(bob.getshieldedbalance(bob_addr), bob_balance) + assert_equal(bob.getshieldbalance(bob_addr), bob_balance) # importsaplingkey onto new node "david" (blockchain rescan, default or True?) d_ipk_addr = david.importsaplingkey(bob_privkey) # Check if amt bob spent is deducted for charlie and david - assert_equal(charlie.getshieldedbalance(ipk_addr["address"]), bob_balance) - assert_equal(david.getshieldedbalance(d_ipk_addr["address"]), bob_balance) + assert_equal(charlie.getshieldbalance(ipk_addr["address"]), bob_balance) + assert_equal(david.getshieldbalance(d_ipk_addr["address"]), bob_balance) if __name__ == '__main__': SaplingkeyImportExportTest().main() diff --git a/test/functional/sapling_malleable_sigs.py b/test/functional/sapling_malleable_sigs.py index 75c0bb275a1d8..e88705e99b2a6 100755 --- a/test/functional/sapling_malleable_sigs.py +++ b/test/functional/sapling_malleable_sigs.py @@ -31,12 +31,12 @@ def run_test(self): node.generate(2) assert_equal(node.getblockcount(), 202) - z_addr = node.getnewshieldedaddress() + z_addr = node.getnewshieldaddress() shield_to = [{"address": z_addr, "amount": Decimal('10')}] # Create rawtx shielding 10 PIV self.log.info("Shielding 10 PIV...") - rawtx = node.rawshieldedsendmany("from_transparent", shield_to)["hex"] + rawtx = node.rawshieldsendmany("from_transparent", shield_to)["hex"] self.log.info("Raw tx created") # Creating malleated tx diff --git a/test/functional/sapling_mempool.py b/test/functional/sapling_mempool.py index 876da3958e557..febc33a629d19 100755 --- a/test/functional/sapling_mempool.py +++ b/test/functional/sapling_mempool.py @@ -35,21 +35,21 @@ def run_test(self): # miner sends a 10 PIV note to Alice self.log.info("Shielding some coins for Alice...") - alice_zaddr = alice.getnewshieldedaddress() - miner.shieldedsendmany("from_transparent", [{"address": alice_zaddr, "amount": Decimal('10.00')}], 1, fee) + alice_zaddr = alice.getnewshieldaddress() + miner.shieldsendmany("from_transparent", [{"address": alice_zaddr, "amount": Decimal('10.00')}], 1, fee) miner.generate(1) self.sync_all() - assert_equal(alice.getshieldedbalance(alice_zaddr), Decimal('10.00')) + assert_equal(alice.getshieldbalance(alice_zaddr), Decimal('10.00')) # Alice creates (but doesn't send) tx_A to transparent address tadd_A self.log.info("Alice creating tx_A...") tadd_A = alice.getnewaddress() - rawTx = alice.rawshieldedsendmany(alice_zaddr, [{"address": tadd_A, "amount": Decimal('9.00')}], 1, fee) + rawTx = alice.rawshieldsendmany(alice_zaddr, [{"address": tadd_A, "amount": Decimal('9.00')}], 1, fee) # Alice creates and sends tx_B, unshielding the same note to tadd_B self.log.info("Alice creating and sending tx_B...") tadd_B = alice.getnewaddress() - txid_B = alice.shieldedsendmany(alice_zaddr, [{"address": tadd_B, "amount": Decimal('9.00')}], 1, fee) + txid_B = alice.shieldsendmany(alice_zaddr, [{"address": tadd_B, "amount": Decimal('9.00')}], 1, fee) # Miner receives tx_B and accepts it in the mempool assert (txid_B in alice.getrawmempool()) @@ -75,15 +75,15 @@ def run_test(self): # miner sends another 10 PIV note to Alice self.log.info("Shielding some more coins for Alice...") - miner.shieldedsendmany("from_transparent", [{"address": alice_zaddr, "amount": Decimal('10.00')}], 1, fee) + miner.shieldsendmany("from_transparent", [{"address": alice_zaddr, "amount": Decimal('10.00')}], 1, fee) miner.generate(1) self.sync_all() - assert_equal(alice.getshieldedbalance(alice_zaddr), Decimal('10.00')) + assert_equal(alice.getshieldbalance(alice_zaddr), Decimal('10.00')) # Alice creates and sends tx_C, unshielding the note to tadd_C self.log.info("Alice creating and sending tx_C...") tadd_C = alice.getnewaddress() - txC_json = alice.rawshieldedsendmany(alice_zaddr, [{"address": tadd_C, "amount": Decimal('9.00')}], 1, fee) + txC_json = alice.rawshieldsendmany(alice_zaddr, [{"address": tadd_C, "amount": Decimal('9.00')}], 1, fee) txid_C = alice.sendrawtransaction(txC_json['hex']) # Miner receives tx_C and accepts it in the mempool diff --git a/test/functional/sapling_supply.py b/test/functional/sapling_supply.py index 2d20a47a01913..2c43272180bea 100755 --- a/test/functional/sapling_supply.py +++ b/test/functional/sapling_supply.py @@ -24,8 +24,8 @@ def generate_and_sync(self, count): def check_shield_supply(self, z_supply): self.log.info("Checking supply...") - assert_equal(self.nodes[0].getsupplyinfo()['shieldedsupply'], z_supply) - self.log.info("OK. Shielded supply is %.8f" % z_supply) + assert_equal(self.nodes[0].getsupplyinfo()['shieldsupply'], z_supply) + self.log.info("OK. Shield supply is %.8f" % z_supply) def run_test(self): fee = 1 @@ -33,20 +33,20 @@ def run_test(self): self.log.info("Generating 101 blocks...") self.generate_and_sync(101) - # Check the shielded supply 0 + # Check the shield supply 0 z_supply = 0 self.check_shield_supply(z_supply) # Send 200 PIV to shield addr1 self.log.info("Shielding 200 PIV...") - z_addr1 = self.nodes[0].getnewshieldedaddress() - txid = self.nodes[0].shieldedsendmany( + z_addr1 = self.nodes[0].getnewshieldaddress() + txid = self.nodes[0].shieldsendmany( "from_transparent", [{'address': z_addr1, 'amount': 200, - 'memo': "first shielded coin!"}], 1, fee) + 'memo': "first shield coin!"}], 1, fee) self.sync_all() # Decrypted transaction details should be correct - pt = self.nodes[0].viewshieldedtransaction(txid) + pt = self.nodes[0].viewshieldtransaction(txid) assert_equal(pt['txid'], txid) assert_equal(len(pt['spends']), 0) assert_equal(len(pt['outputs']), 1) @@ -54,11 +54,11 @@ def run_test(self): assert_equal(out['output'], 0) assert_equal(out['address'], z_addr1) assert_equal(out['outgoing'], False) - assert_equal(out['memoStr'], "first shielded coin!") + assert_equal(out['memoStr'], "first shield coin!") assert_equal(out['value'], Decimal('200')) assert_equal(out['valueSat'], 20000000000) - # Check the shielded supply + # Check the shield supply self.generate_and_sync(5) z_supply += 200 self.check_shield_supply(z_supply) @@ -66,17 +66,17 @@ def run_test(self): # Deshield 100 coins self.log.info("Deshielding 100 PIV...") t_addr1 = self.nodes[0].getnewaddress() - txid = self.nodes[0].shieldedsendmany( - "from_shielded", [{'address': t_addr1, 'amount': 100}], 1, fee) + txid = self.nodes[0].shieldsendmany( + "from_shield", [{'address': t_addr1, 'amount': 100}], 1, fee) self.sync_all() # Decrypted transaction details should be correct - pt = self.nodes[0].viewshieldedtransaction(txid) + pt = self.nodes[0].viewshieldtransaction(txid) assert_equal(pt['txid'], txid) assert_equal(len(pt['spends']), 1) assert_equal(len(pt['outputs']), 1) - # Check the shielded supply + # Check the shield supply self.generate_and_sync(1) z_supply -= (100 + fee) self.check_shield_supply(z_supply) diff --git a/test/functional/sapling_wallet.py b/test/functional/sapling_wallet.py index 85322edd47a6c..b8b02a4b891da 100755 --- a/test/functional/sapling_wallet.py +++ b/test/functional/sapling_wallet.py @@ -44,16 +44,16 @@ def run_test(self): self.sync_all() assert_equal(self.nodes[1].getblockcount(), 202) taddr1 = self.nodes[1].getnewaddress() - saplingAddr0 = self.nodes[0].getnewshieldedaddress() - saplingAddr1 = self.nodes[1].getnewshieldedaddress() + saplingAddr0 = self.nodes[0].getnewshieldaddress() + saplingAddr1 = self.nodes[1].getnewshieldaddress() # Verify addresses - assert(saplingAddr0 in self.nodes[0].listshieldedaddresses()) - assert(saplingAddr1 in self.nodes[1].listshieldedaddresses()) + assert(saplingAddr0 in self.nodes[0].listshieldaddresses()) + assert(saplingAddr1 in self.nodes[1].listshieldaddresses()) # Verify balance - assert_equal(self.nodes[0].getshieldedbalance(saplingAddr0), Decimal('0')) - assert_equal(self.nodes[1].getshieldedbalance(saplingAddr1), Decimal('0')) + assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('0')) + assert_equal(self.nodes[1].getshieldbalance(saplingAddr1), Decimal('0')) assert_equal(self.nodes[1].getreceivedbyaddress(taddr1), Decimal('0')) recipients = [{"address": saplingAddr0, "amount": Decimal('10')}] @@ -62,20 +62,20 @@ def run_test(self): fee_too_low = 0.001 self.log.info("Trying to send a transaction with fee too low...") assert_raises_rpc_error(-4, "Fee set (%.3f) too low. Must be at least" % fee_too_low, - self.nodes[0].rawshieldedsendmany, + self.nodes[0].rawshieldsendmany, "from_transparent", recipients, 1, fee_too_low) # Try fee too high. fee_too_high = 20 self.log.info("Good. It was not possible. Now try a tx with fee too high...") assert_raises_rpc_error(-4, "The transaction fee is too high: %.2f >" % fee_too_high, - self.nodes[0].rawshieldedsendmany, + self.nodes[0].rawshieldsendmany, "from_transparent", recipients, 1, fee_too_high) # Trying to send a rawtx with low fee directly self.log.info("Good. It was not possible. Now try with a raw tx...") self.restart_node(0, extra_args=self.extra_args[0]+['-minrelaytxfee=0.0000001']) - rawtx = self.nodes[0].rawshieldedsendmany("from_transparent", recipients, 1)["hex"] + rawtx = self.nodes[0].rawshieldsendmany("from_transparent", recipients, 1)["hex"] self.restart_node(0, extra_args=self.extra_args[0]) connect_nodes(self.nodes[0], 1) assert_raises_rpc_error(-26, "insufficient fee", @@ -88,11 +88,11 @@ def run_test(self): # Node 0 shields some funds # taddr -> Sapling self.log.info("TX 1: shield funds from specified transparent address.") - mytxid1 = self.nodes[0].shieldedsendmany(get_coinstake_address(self.nodes[0]), recipients, 1, fee) + mytxid1 = self.nodes[0].shieldsendmany(get_coinstake_address(self.nodes[0]), recipients, 1, fee) # shield more funds automatically selecting the transparent inputs self.log.info("TX 2: shield funds from any transparent address.") - mytxid2 = self.nodes[0].shieldedsendmany("from_transparent", recipients, 1, fee) + mytxid2 = self.nodes[0].shieldsendmany("from_transparent", recipients, 1, fee) # Verify priority of tx is INF_PRIORITY, defined as 1E+25 (10000000000000000000000000) self.check_tx_priority([mytxid1, mytxid2]) @@ -103,7 +103,7 @@ def run_test(self): # shield more funds creating and then sending a raw transaction self.log.info("TX 3: shield funds creating and sending raw transaction.") - tx_json = self.nodes[0].rawshieldedsendmany("from_transparent", recipients, 1, fee) + tx_json = self.nodes[0].rawshieldsendmany("from_transparent", recipients, 1, fee) # Check SPORK_20 for sapling maintenance mode SPORK_20 = "SPORK_20_SAPLING_MAINTENANCE" @@ -115,7 +115,7 @@ def run_test(self): # Try with RPC... assert_raises_rpc_error(-8, "Invalid parameter, Sapling not active yet", - self.nodes[0].shieldedsendmany, "from_transparent", recipients, 1, fee) + self.nodes[0].shieldsendmany, "from_transparent", recipients, 1, fee) # Disable SPORK_20 and retry sleep(5) @@ -132,8 +132,8 @@ def run_test(self): self.sync_all() # Verify balance - assert_equal(self.nodes[0].getshieldedbalance(saplingAddr0), Decimal('30')) - assert_equal(self.nodes[1].getshieldedbalance(saplingAddr1), Decimal('0')) + assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('30')) + assert_equal(self.nodes[1].getshieldbalance(saplingAddr1), Decimal('0')) assert_equal(self.nodes[1].getreceivedbyaddress(taddr1), Decimal('0')) self.log.info("Balances check out") @@ -142,12 +142,12 @@ def run_test(self): tip_hash = self.nodes[0].getbestblockhash() self.nodes[0].invalidateblock(tip_hash) assert tip_hash != self.nodes[0].getbestblockhash() - assert_equal(self.nodes[0].getshieldedbalance(saplingAddr0), Decimal('20')) - self.log.info("Now trying to connect block with shielded tx, when SPORK_20 is active") + assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('20')) + self.log.info("Now trying to connect block with shield tx, when SPORK_20 is active") self.activate_spork(0, SPORK_20) self.nodes[0].reconsiderblock(tip_hash) assert tip_hash != self.nodes[0].getbestblockhash() # Block NOT connected - assert_equal(self.nodes[0].getshieldedbalance(saplingAddr0), Decimal('20')) + assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('20')) self.log.info("Good. Not possible.") # Deactivate SPORK_20 and reconnect @@ -155,33 +155,33 @@ def run_test(self): self.deactivate_spork(0, SPORK_20) self.nodes[0].reconsiderblock(tip_hash) assert_equal(tip_hash, self.nodes[0].getbestblockhash()) # Block connected - assert_equal(self.nodes[0].getshieldedbalance(saplingAddr0), Decimal('30')) + assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('30')) self.log.info("Reconnected after deactivation of SPORK_20. Balance restored.") connect_nodes(self.nodes[0], 1) - # Node 0 sends some shielded funds to node 1 + # Node 0 sends some shield funds to node 1 # Sapling -> Sapling # -> Sapling (change) - self.log.info("TX 4: shielded transaction from specified sapling address.") + self.log.info("TX 4: shield transaction from specified sapling address.") recipients4 = [{"address": saplingAddr1, "amount": Decimal('10')}] - mytxid4 = self.nodes[0].shieldedsendmany(saplingAddr0, recipients4, 1, fee) + mytxid4 = self.nodes[0].shieldsendmany(saplingAddr0, recipients4, 1, fee) self.check_tx_priority([mytxid4]) self.nodes[2].generate(1) self.sync_all() - # Send more shielded funds (this time with automatic selection of the source) - self.log.info("TX 5: shielded transaction from any sapling address.") + # Send more shield funds (this time with automatic selection of the source) + self.log.info("TX 5: shield transaction from any sapling address.") recipients5 = [{"address": saplingAddr1, "amount": Decimal('5')}] - mytxid5 = self.nodes[0].shieldedsendmany("from_shielded", recipients5, 1, fee) + mytxid5 = self.nodes[0].shieldsendmany("from_shield", recipients5, 1, fee) self.check_tx_priority([mytxid5]) self.nodes[2].generate(1) self.sync_all() - # Send more shielded funds (with create + send raw transaction) - self.log.info("TX 6: shielded raw transaction.") - tx_json = self.nodes[0].rawshieldedsendmany("from_shielded", recipients5, 1, fee) + # Send more shield funds (with create + send raw transaction) + self.log.info("TX 6: shield raw transaction.") + tx_json = self.nodes[0].rawshieldsendmany("from_shield", recipients5, 1, fee) mytxid6 = self.nodes[0].sendrawtransaction(tx_json["hex"]) self.check_tx_priority([mytxid6]) @@ -189,10 +189,10 @@ def run_test(self): self.sync_all() # Shield more funds to a different address to verify multi-source notes spending - saplingAddr2 = self.nodes[0].getnewshieldedaddress() + saplingAddr2 = self.nodes[0].getnewshieldaddress() self.log.info("TX 7: shield funds to later verify multi source notes spending.") recipients = [{"address": saplingAddr2, "amount": Decimal('10')}] - mytxid7 = self.nodes[0].shieldedsendmany(get_coinstake_address(self.nodes[0]), recipients, 1, fee) + mytxid7 = self.nodes[0].shieldsendmany(get_coinstake_address(self.nodes[0]), recipients, 1, fee) self.check_tx_priority([mytxid7]) self.nodes[2].generate(5) @@ -202,42 +202,42 @@ def run_test(self): tAddr0 = self.nodes[0].getnewaddress() self.log.info("TX 8: verifying multi source notes spending.") recipients = [{"address": tAddr0, "amount": Decimal('11')}] - mytxid8 = self.nodes[0].shieldedsendmany("from_shielded", recipients, 1, fee) + mytxid8 = self.nodes[0].shieldsendmany("from_shield", recipients, 1, fee) self.check_tx_priority([mytxid8]) self.nodes[2].generate(1) self.sync_all() # Verify balance - assert_equal(self.nodes[0].getshieldedbalance(saplingAddr0), Decimal('3')) # 30 received - (20 sent + 3 fee) - 4 sent - assert_equal(self.nodes[1].getshieldedbalance(saplingAddr1), Decimal('20')) # 20 received - assert_equal(self.nodes[0].getshieldedbalance(saplingAddr2), Decimal('2')) # 10 received - 10 sent + 2 change + assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('3')) # 30 received - (20 sent + 3 fee) - 4 sent + assert_equal(self.nodes[1].getshieldbalance(saplingAddr1), Decimal('20')) # 20 received + assert_equal(self.nodes[0].getshieldbalance(saplingAddr2), Decimal('2')) # 10 received - 10 sent + 2 change assert_equal(self.nodes[1].getreceivedbyaddress(taddr1), Decimal('0')) - assert_equal(self.nodes[0].getshieldedbalance(), Decimal('5')) + assert_equal(self.nodes[0].getshieldbalance(), Decimal('5')) self.log.info("Balances check out") - # Node 1 sends some shielded funds to node 0, as well as unshielding + # Node 1 sends some shield funds to node 0, as well as unshielding # Sapling -> Sapling # -> taddr # -> Sapling (change) self.log.info("TX 10: deshield funds from specified sapling address.") recipients7 = [{"address": saplingAddr0, "amount": Decimal('8')}] recipients7.append({"address": taddr1, "amount": Decimal('10')}) - mytxid7 = self.nodes[1].shieldedsendmany(saplingAddr1, recipients7, 1, fee) + mytxid7 = self.nodes[1].shieldsendmany(saplingAddr1, recipients7, 1, fee) self.check_tx_priority([mytxid7]) self.nodes[2].generate(1) self.sync_all() # Verify balance - assert_equal(self.nodes[0].getshieldedbalance(saplingAddr0), Decimal('11')) # 3 prev balance + 8 received - assert_equal(self.nodes[1].getshieldedbalance(saplingAddr1), Decimal('1')) # 20 prev balance - (18 sent + 1 fee) + assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('11')) # 3 prev balance + 8 received + assert_equal(self.nodes[1].getshieldbalance(saplingAddr1), Decimal('1')) # 20 prev balance - (18 sent + 1 fee) assert_equal(self.nodes[1].getreceivedbyaddress(taddr1), Decimal('10')) self.log.info("Balances check out") # Verify existence of Sapling related JSON fields resp = self.nodes[0].getrawtransaction(mytxid7, 1) - assert_equal(Decimal(resp['valueBalance']), Decimal('11.00')) # 20 shielded input - 8 shielded spend - 1 change + assert_equal(Decimal(resp['valueBalance']), Decimal('11.00')) # 20 shield input - 8 shield spend - 1 change assert_equal(len(resp['vShieldedSpend']), 3) assert_equal(len(resp['vShieldedOutput']), 2) assert('bindingSig' in resp) @@ -262,26 +262,26 @@ def run_test(self): sk0 = self.nodes[0].exportsaplingkey(saplingAddr0) saplingAddrInfo0 = self.nodes[2].importsaplingkey(sk0, "yes") assert_equal(saplingAddrInfo0["address"], saplingAddr0) - assert_equal(self.nodes[2].getshieldedbalance(saplingAddrInfo0["address"]), Decimal('11')) + assert_equal(self.nodes[2].getshieldbalance(saplingAddrInfo0["address"]), Decimal('11')) sk1 = self.nodes[1].exportsaplingkey(saplingAddr1) saplingAddrInfo1 = self.nodes[2].importsaplingkey(sk1, "yes") assert_equal(saplingAddrInfo1["address"], saplingAddr1) - assert_equal(self.nodes[2].getshieldedbalance(saplingAddrInfo1["address"]), Decimal('1')) + assert_equal(self.nodes[2].getshieldbalance(saplingAddrInfo1["address"]), Decimal('1')) # Verify importing a viewing key will update the nullifiers and witnesses correctly self.log.info("Checking exporting/importing a viewing key...") extfvk0 = self.nodes[0].exportsaplingviewingkey(saplingAddr0) saplingAddrInfo0 = self.nodes[3].importsaplingviewingkey(extfvk0, "yes") assert_equal(saplingAddrInfo0["address"], saplingAddr0) - assert_equal(Decimal(self.nodes[3].getshieldedbalance(saplingAddrInfo0["address"], 1, True)), Decimal('11')) + assert_equal(Decimal(self.nodes[3].getshieldbalance(saplingAddrInfo0["address"], 1, True)), Decimal('11')) extfvk1 = self.nodes[1].exportsaplingviewingkey(saplingAddr1) saplingAddrInfo1 = self.nodes[3].importsaplingviewingkey(extfvk1, "yes") assert_equal(saplingAddrInfo1["address"], saplingAddr1) - assert_equal(self.nodes[3].getshieldedbalance(saplingAddrInfo1["address"], 1, True), Decimal('1')) + assert_equal(self.nodes[3].getshieldbalance(saplingAddrInfo1["address"], 1, True), Decimal('1')) # no balance in the wallet - assert_equal(self.nodes[3].getshieldedbalance(), Decimal('0')) + assert_equal(self.nodes[3].getshieldbalance(), Decimal('0')) # watch only balance - assert_equal(self.nodes[3].getshieldedbalance("*", 1, True), Decimal('12.00')) + assert_equal(self.nodes[3].getshieldbalance("*", 1, True), Decimal('12.00')) # Now shield some funds using sendmany self.log.info("TX11: Shielding coins to multiple destinations with sendmany RPC...") @@ -292,7 +292,7 @@ def run_test(self): self.log.info("Done. Checking details and balances...") # Decrypted transaction details should be correct - pt = self.nodes[0].viewshieldedtransaction(mytxid11) + pt = self.nodes[0].viewshieldtransaction(mytxid11) fee = pt["fee"] assert_equal(pt['txid'], mytxid11) assert_equal(len(pt['spends']), 0) @@ -318,9 +318,9 @@ def run_test(self): # Verify balance self.nodes[2].generate(1) self.sync_all() - assert_equal(self.nodes[0].getshieldedbalance(saplingAddr0), Decimal('19')) # 11 prev balance + 8 received - assert_equal(self.nodes[1].getshieldedbalance(saplingAddr1), Decimal('2')) # 1 prev balance + 1 received - assert_equal(self.nodes[0].getshieldedbalance(saplingAddr2), Decimal('2.5')) # 2 prev balance + 0.5 received + assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('19')) # 11 prev balance + 8 received + assert_equal(self.nodes[1].getshieldbalance(saplingAddr1), Decimal('2')) # 1 prev balance + 1 received + assert_equal(self.nodes[0].getshieldbalance(saplingAddr2), Decimal('2.5')) # 2 prev balance + 0.5 received # Balance of node 0 is: prev_balance - 1 PIV (+fee) sent externally + 250 PIV matured coinbase assert_equal(self.nodes[0].getbalance(), satoshi_round(prev_balance + Decimal('249') - Decimal(fee))) @@ -332,7 +332,7 @@ def run_test(self): self.log.info("Done. Checking details and balances...") # Decrypted transaction details should be correct - pt = self.nodes[0].viewshieldedtransaction(mytxid12) + pt = self.nodes[0].viewshieldtransaction(mytxid12) fee = pt["fee"] assert_equal(pt['txid'], mytxid12) assert_equal(len(pt['spends']), 0) @@ -345,7 +345,7 @@ def run_test(self): # Verify balance self.nodes[2].generate(1) self.sync_all() - assert_equal(self.nodes[0].getshieldedbalance(saplingAddr0), Decimal('29')) # 19 prev balance + 10 received + assert_equal(self.nodes[0].getshieldbalance(saplingAddr0), Decimal('29')) # 19 prev balance + 10 received self.log.info("All good.") diff --git a/test/functional/sapling_wallet_anchorfork.py b/test/functional/sapling_wallet_anchorfork.py index dcf7a25e7a689..3230015a33026 100755 --- a/test/functional/sapling_wallet_anchorfork.py +++ b/test/functional/sapling_wallet_anchorfork.py @@ -37,12 +37,12 @@ def run_test (self): # At this point in time, commitment tree is the empty root - # Node 0 creates a shielded transaction + # Node 0 creates a shield transaction mytaddr0 = get_coinstake_address(self.nodes[0]) - myzaddr0 = self.nodes[0].getnewshieldedaddress() + myzaddr0 = self.nodes[0].getnewshieldaddress() recipients = [] recipients.append({"address":myzaddr0, "amount": Decimal('10.0') - Decimal('0.0001')}) - txid = self.nodes[0].shieldedsendmany(mytaddr0, recipients) + txid = self.nodes[0].shieldsendmany(mytaddr0, recipients) # Sync up mempools and mine the transaction. All nodes have the same anchor. self.sync_all() @@ -69,17 +69,17 @@ def run_test (self): assert_equal(self.nodes[1].getblockcount(), self.nodes[2].getblockcount()) assert(self.nodes[2].getblockcount() != self.nodes[0].getblockcount()) - # Partition A, node 0 creates a shielded transaction + # Partition A, node 0 creates a shield transaction recipients = [] recipients.append({"address":myzaddr0, "amount": Decimal('10.0') - Decimal('0.0001')}) - txid = self.nodes[0].shieldedsendmany(mytaddr0, recipients) + txid = self.nodes[0].shieldsendmany(mytaddr0, recipients) rawhex = self.nodes[0].getrawtransaction(txid) # Partition A, node 0 mines a block with the transaction self.nodes[0].generate(1) self.sync_all([self.nodes[1:3]]) - # Partition B, node 1 mines the same shielded transaction + # Partition B, node 1 mines the same shield transaction txid2 = self.nodes[1].sendrawtransaction(rawhex) assert_equal(txid, txid2) self.nodes[1].generate(1) diff --git a/test/functional/sapling_wallet_listreceived.py b/test/functional/sapling_wallet_listreceived.py index afcf6ff97714d..7c9a20acfe609 100755 --- a/test/functional/sapling_wallet_listreceived.py +++ b/test/functional/sapling_wallet_listreceived.py @@ -37,28 +37,28 @@ def run_test(self): height = 214 self.generate_and_sync(height+1) taddr = self.nodes[1].getnewaddress() - shield_addr1 = self.nodes[1].getnewshieldedaddress() - shield_addrExt = self.nodes[3].getnewshieldedaddress() + shield_addr1 = self.nodes[1].getnewshieldaddress() + shield_addrExt = self.nodes[3].getnewshieldaddress() self.nodes[0].sendtoaddress(taddr, 6.0) # node_1 in taddr with 6 PIV. self.generate_and_sync(height+2) # Try to send with an oversized memo assert_raises_rpc_error(-4, "Memo size of 513 is too big, maximum allowed is 512", - self.nodes[1].shieldedsendmany, taddr, + self.nodes[1].shieldsendmany, taddr, [{'address': shield_addr1, 'amount': 2, 'memo': too_big_memo_str}]) # Fixed fee fee = 0.5 # Send 1 PIV to shield addr1 - txid = self.nodes[1].shieldedsendmany(taddr, [ # node_1 with 6 PIV sending them all (fee is 0.1 PIV) + txid = self.nodes[1].shieldsendmany(taddr, [ # node_1 with 6 PIV sending them all (fee is 0.1 PIV) {'address': shield_addr1, 'amount': 2, 'memo': my_memo_str}, {'address': shield_addrExt, 'amount': 3}, ], 1, fee) self.sync_all() # Decrypted transaction details should be correct - pt = self.nodes[1].viewshieldedtransaction(txid) + pt = self.nodes[1].viewshieldtransaction(txid) assert_equal(pt['txid'], txid) assert_equal(len(pt['spends']), 0) assert_equal(len(pt['outputs']), 2) @@ -82,13 +82,13 @@ def run_test(self): found[1] = True assert_equal(found, [True] * 2) - r = self.nodes[1].listreceivedbyshieldedaddress(shield_addr1) + r = self.nodes[1].listreceivedbyshieldaddress(shield_addr1) assert_true(0 == len(r), "Should have received no confirmed note") c = self.nodes[1].getsaplingnotescount() assert_true(0 == c, "Count of confirmed notes should be 0") # No confirmation required, one note should be present - r = self.nodes[1].listreceivedbyshieldedaddress(shield_addr1, 0) + r = self.nodes[1].listreceivedbyshieldaddress(shield_addr1, 0) assert_true(1 == len(r), "Should have received one (unconfirmed) note") assert_equal(txid, r[0]['txid']) assert_equal(2, r[0]['amount']) @@ -112,7 +112,7 @@ def run_test(self): r[0]['blockheight'] = height + 3 # Require one confirmation, note should be present - r2 = self.nodes[1].listreceivedbyshieldedaddress(shield_addr1) + r2 = self.nodes[1].listreceivedbyshieldaddress(shield_addr1) # As time will be different (tx was included in a block), need to remove it from the dict assert_true(r[0]['blocktime'] != r2[0]['blocktime']) del r[0]['blocktime'] @@ -121,14 +121,14 @@ def run_test(self): assert_equal(r, r2) # Get the note nullifier - lsu = self.nodes[1].listshieldedunspent(); + lsu = self.nodes[1].listshieldunspent(); assert_equal(len(lsu), 1) nullifier = lsu[0]["nullifier"] # Generate some change by sending part of shield_addr1 to shield_addr2 txidPrev = txid - shield_addr2 = self.nodes[1].getnewshieldedaddress() - txid = self.nodes[1].shieldedsendmany(shield_addr1, # shield_addr1 has 2 PIV, send 0.6 PIV + 0.5 PIV fee + shield_addr2 = self.nodes[1].getnewshieldaddress() + txid = self.nodes[1].shieldsendmany(shield_addr1, # shield_addr1 has 2 PIV, send 0.6 PIV + 0.5 PIV fee [{'address': shield_addr2, 'amount': 0.6, "memo": non_ascii_memo_str}], 1, fee) # change 0.9 self.sync_all() @@ -139,7 +139,7 @@ def run_test(self): assert_equal(nullifier, tx_json["vShieldedSpend"][0]["nullifier"]) # Decrypted transaction details should be correct - pt = self.nodes[1].viewshieldedtransaction(txid) + pt = self.nodes[1].viewshieldtransaction(txid) assert_equal(pt['txid'], txid) assert_equal(len(pt['spends']), 1) assert_equal(len(pt['outputs']), 2) @@ -171,7 +171,7 @@ def run_test(self): assert_equal(found, [True] * 2) # shield_addr1 should have a note with change - r = self.nodes[1].listreceivedbyshieldedaddress(shield_addr1, 0) + r = self.nodes[1].listreceivedbyshieldaddress(shield_addr1, 0) r = sorted(r, key = lambda received: received['amount']) assert_true(2 == len(r), "shield_addr1 Should have received 2 notes") @@ -186,7 +186,7 @@ def run_test(self): assert_equal(my_memo_hex, r[1]['memo']) # shield_addr2 should not have change - r = self.nodes[1].listreceivedbyshieldedaddress(shield_addr2, 0) + r = self.nodes[1].listreceivedbyshieldaddress(shield_addr2, 0) r = sorted(r, key = lambda received: received['amount']) assert_true(1 == len(r), "shield_addr2 Should have received 1 notes") assert_equal(txid, r[0]['txid']) diff --git a/test/functional/sapling_wallet_nullifiers.py b/test/functional/sapling_wallet_nullifiers.py index 24345b2b69867..b8d879808adf7 100755 --- a/test/functional/sapling_wallet_nullifiers.py +++ b/test/functional/sapling_wallet_nullifiers.py @@ -22,25 +22,25 @@ def set_test_params(self): def run_test (self): self.nodes[0].generate(1) # activate Sapling - # add shielded addr to node 0 - myzaddr0 = self.nodes[0].getnewshieldedaddress() + # add shield addr to node 0 + myzaddr0 = self.nodes[0].getnewshieldaddress() - # send node 0 taddr to shielded addr to get out of coinbase + # send node 0 taddr to shield addr to get out of coinbase # Tests using the default cached chain have one address per coinbase output mytaddr = get_coinstake_address(self.nodes[0]) recipients = [] recipients.append({"address":myzaddr0, "amount":Decimal('10.0') - Decimal('1')}) # utxo amount less fee - txid = self.nodes[0].shieldedsendmany(mytaddr, recipients) + txid = self.nodes[0].shieldsendmany(mytaddr, recipients) self.sync_all() self.nodes[0].generate(1) self.sync_all() - # add shielded addr to node 2 - myzaddr = self.nodes[2].getnewshieldedaddress() + # add shield addr to node 2 + myzaddr = self.nodes[2].getnewshieldaddress() - # import node 2 shielded addr into node 1 + # import node 2 shield addr into node 1 myzkey = self.nodes[2].exportsaplingkey(myzaddr) self.nodes[1].importsaplingkey(myzkey) @@ -54,43 +54,43 @@ def run_test (self): connect_nodes_bi(self.nodes, 3, 1) self.sync_all() - # send node 0 shielded addr to note 2 zaddr + # send node 0 shield addr to note 2 zaddr recipients = [] recipients.append({"address":myzaddr, "amount":7.0}) - txid = self.nodes[0].shieldedsendmany(myzaddr0, recipients) + txid = self.nodes[0].shieldsendmany(myzaddr0, recipients) self.sync_all() self.nodes[0].generate(1) self.sync_all() - # check shielded addr balance + # check shield addr balance zsendmanynotevalue = Decimal('7.0') - assert_equal(self.nodes[2].getshieldedbalance(myzaddr), zsendmanynotevalue) - assert_equal(self.nodes[1].getshieldedbalance(myzaddr), zsendmanynotevalue) + assert_equal(self.nodes[2].getshieldbalance(myzaddr), zsendmanynotevalue) + assert_equal(self.nodes[1].getshieldbalance(myzaddr), zsendmanynotevalue) - # add shielded addr to node 3 - myzaddr3 = self.nodes[3].getnewshieldedaddress() + # add shield addr to node 3 + myzaddr3 = self.nodes[3].getnewshieldaddress() - # send node 2 shielded addr to note 3 shielded addr + # send node 2 shield addr to note 3 shield addr recipients = [] recipients.append({"address":myzaddr3, "amount":2.0}) - txid = self.nodes[2].shieldedsendmany(myzaddr, recipients) + txid = self.nodes[2].shieldsendmany(myzaddr, recipients) self.sync_all() self.nodes[2].generate(1) self.sync_all() - # check shielded addr balance + # check shield addr balance zsendmany2notevalue = Decimal('2.0') - zsendmanyfee = Decimal(self.nodes[2].viewshieldedtransaction(txid)['fee']) + zsendmanyfee = Decimal(self.nodes[2].viewshieldtransaction(txid)['fee']) zaddrremaining = zsendmanynotevalue - zsendmany2notevalue - zsendmanyfee - assert_equal(self.nodes[3].getshieldedbalance(myzaddr3), zsendmany2notevalue) - assert_equal(self.nodes[2].getshieldedbalance(myzaddr), zaddrremaining) - assert_equal(self.nodes[1].getshieldedbalance(myzaddr), zaddrremaining) + assert_equal(self.nodes[3].getshieldbalance(myzaddr3), zsendmany2notevalue) + assert_equal(self.nodes[2].getshieldbalance(myzaddr), zaddrremaining) + assert_equal(self.nodes[1].getshieldbalance(myzaddr), zaddrremaining) - # send node 2 shielded addr on node 1 to taddr + # send node 2 shield addr on node 1 to taddr # This requires that node 1 be unlocked, which triggers caching of # uncached nullifiers. self.nodes[1].walletpassphrase("test", 600) @@ -98,26 +98,26 @@ def run_test (self): recipients = [] recipients.append({"address":mytaddr1, "amount":1.0}) - txid = self.nodes[1].shieldedsendmany(myzaddr, recipients) + txid = self.nodes[1].shieldsendmany(myzaddr, recipients) self.sync_all() self.nodes[1].generate(1) self.sync_all() - # check shielded addr balance + # check shield addr balance # Now that the encrypted wallet has been unlocked, the note nullifiers # have been cached and spent notes can be detected. Thus the two wallets # are in agreement once more. zsendmany3notevalue = Decimal('1.0') - zsendmanyfee = Decimal(self.nodes[1].viewshieldedtransaction(txid)['fee']) + zsendmanyfee = Decimal(self.nodes[1].viewshieldtransaction(txid)['fee']) zaddrremaining2 = zaddrremaining - zsendmany3notevalue - zsendmanyfee - assert_equal(self.nodes[1].getshieldedbalance(myzaddr), zaddrremaining2) - assert_equal(self.nodes[2].getshieldedbalance(myzaddr), zaddrremaining2) + assert_equal(self.nodes[1].getshieldbalance(myzaddr), zaddrremaining2) + assert_equal(self.nodes[2].getshieldbalance(myzaddr), zaddrremaining2) # Test viewing keys node3mined = Decimal('6250.0') - assert_equal(self.nodes[3].getshieldedbalance(), zsendmany2notevalue) + assert_equal(self.nodes[3].getshieldbalance(), zsendmany2notevalue) assert_equal(self.nodes[3].getbalance(1, False, True, False), node3mined) # Add node 1 address and node 2 viewing key to node 3 @@ -129,8 +129,8 @@ def run_test (self): assert_equal(importvk_result["address"], myzaddr) # Check the address has been imported - assert_equal(myzaddr in self.nodes[3].listshieldedaddresses(), False) - assert_equal(myzaddr in self.nodes[3].listshieldedaddresses(True), True) + assert_equal(myzaddr in self.nodes[3].listshieldaddresses(), False) + assert_equal(myzaddr in self.nodes[3].listshieldaddresses(True), True) # Node 3 should see the same received notes as node 2; however, there are 2 things: # - Some of the notes were change for node 2 but not for node 3. @@ -139,8 +139,8 @@ def run_test (self): # Aside from that the received notes should be the same. So, # group by txid and then check that all properties aside from # change are equal. - node2Received = dict([r['txid'], r] for r in self.nodes[2].listreceivedbyshieldedaddress(myzaddr)) - node3Received = dict([r['txid'], r] for r in self.nodes[3].listreceivedbyshieldedaddress(myzaddr)) + node2Received = dict([r['txid'], r] for r in self.nodes[2].listreceivedbyshieldaddress(myzaddr)) + node3Received = dict([r['txid'], r] for r in self.nodes[3].listreceivedbyshieldaddress(myzaddr)) assert_equal(len(node2Received), len(node2Received)) for txid in node2Received: received2 = node2Received[txid] @@ -154,16 +154,16 @@ def run_test (self): # Node 3's balances should be unchanged without explicitly requesting # to include watch-only balances - assert_equal(self.nodes[3].getshieldedbalance(), zsendmany2notevalue) + assert_equal(self.nodes[3].getshieldbalance(), zsendmany2notevalue) assert_equal(self.nodes[3].getbalance(1, False, True, False), node3mined) - assert_equal(self.nodes[3].getshieldedbalance("*", 1, True), zsendmany2notevalue + zaddrremaining2) + assert_equal(self.nodes[3].getshieldbalance("*", 1, True), zsendmany2notevalue + zaddrremaining2) assert_equal(self.nodes[3].getbalance(1, True, True, False), node3mined + Decimal('1.0')) # Check individual balances reflect the above assert_equal(self.nodes[3].getreceivedbyaddress(mytaddr1), Decimal('1.0')) - assert_equal(self.nodes[3].getshieldedbalance(myzaddr), Decimal('0.0')) - assert_equal(self.nodes[3].getshieldedbalance(myzaddr, 1, True), zaddrremaining2) + assert_equal(self.nodes[3].getshieldbalance(myzaddr), Decimal('0.0')) + assert_equal(self.nodes[3].getshieldbalance(myzaddr, 1, True), zaddrremaining2) if __name__ == '__main__': WalletNullifiersTest().main () diff --git a/test/functional/sapling_wallet_persistence.py b/test/functional/sapling_wallet_persistence.py index 7f8523d634797..61c46530477a4 100755 --- a/test/functional/sapling_wallet_persistence.py +++ b/test/functional/sapling_wallet_persistence.py @@ -14,14 +14,14 @@ def set_test_params(self): self.setup_clean_chain = True def run_test(self): - sapling_addr = self.nodes[0].getnewshieldedaddress() - addresses = self.nodes[0].listshieldedaddresses() + sapling_addr = self.nodes[0].getnewshieldaddress() + addresses = self.nodes[0].listshieldaddresses() # make sure the node has the addresss assert_true(sapling_addr in addresses, "Should contain address before restart") # restart the nodes self.stop_node(0) self.start_node(0) - addresses = self.nodes[0].listshieldedaddresses() + addresses = self.nodes[0].listshieldaddresses() # make sure we still have the address after restarting assert_true(sapling_addr in addresses, "Should contain address after restart")