diff --git a/src/init.cpp b/src/init.cpp index 36ed5e0cb..7f660c555 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6b145baf6..aa22f7ef0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -70,8 +70,8 @@ using namespace libzcash; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; -const std::string ADDR_TYPE_SPROUT = "sprout"; -const std::string ADDR_TYPE_SAPLING = "sapling"; +const std::string ADDR_TYPE_SAPLING = "sapling"; +const std::string ADDR_TYPE_DONOTREMEMBER = "donotremember"; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern int32_t KOMODO_INSYNC; uint32_t komodo_segid32(char *coinaddr); @@ -3716,15 +3716,16 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk throw runtime_error( "z_getnewaddress ( type )\n" "\nReturns a new shielded address for receiving payments.\n" - "\nWith no arguments, returns a Sprout address.\n" + "\nWith no arguments, returns a Sapling address.\n" + "\nBe very careful with 'donotremember' address type, the extended spending key (xsk) of that address is not stored in wallet.dat!\n" "\nArguments:\n" - "1. \"type\" (string, optional, default=\"" + defaultType + "\") The type of address. One of [\"" - + ADDR_TYPE_SAPLING + "\"].\n" + "1. \"type\" (string, optional, default=\"" + defaultType + "\") The type of address. Either "+ ADDR_TYPE_SAPLING + " or " + ADDR_TYPE_DONOTREMEMBER + " .\n" "\nResult:\n" "\"" + strprintf("%s",komodo_chainname()) + "_address\" (string) The new shielded address.\n" "\nExamples:\n" + HelpExampleCli("z_getnewaddress", "") + HelpExampleCli("z_getnewaddress", ADDR_TYPE_SAPLING) + + HelpExampleCli("z_getnewaddress", ADDR_TYPE_DONOTREMEMBER) ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -3735,11 +3736,17 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk if (params.size() > 0) { addrType = params[0].get_str(); } - if (addrType == ADDR_TYPE_SAPLING) { return EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey()); + } else if (addrType == ADDR_TYPE_DONOTREMEMBER) { + bool addToWallet = false; + auto zaddr = EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey(addToWallet)); + if(fZdebug) { + fprintf(stderr,"%s: Sietch zaddr=%s created, xsk not stored in wallet.dat!\n", __FUNCTION__, zaddr.c_str() ); + } + return zaddr; } else { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid address type!"); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid address type! Try " + ADDR_TYPE_SAPLING + " or " + ADDR_TYPE_DONOTREMEMBER); } } @@ -4049,7 +4056,7 @@ UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& my "\nResult:\n" "{\n" " \"transparent\": xxxxx, (numeric) the total balance of transparent funds\n" - " \"private\": xxxxx, (numeric) the total balance of private funds (in both Sprout and Sapling addresses)\n" + " \"private\": xxxxx, (numeric) the total balance of shielded funds\n" " \"total\": xxxxx, (numeric) the total balance of both transparent and private funds\n" "}\n" "\nExamples:\n" diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b52ccdb9f..a9e79a3a3 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -127,7 +127,7 @@ libzcash::SproutPaymentAddress CWallet::GenerateNewSproutZKey() } // Generate a new Sapling spending key and return its public payment address -SaplingPaymentAddress CWallet::GenerateNewSaplingZKey() +SaplingPaymentAddress CWallet::GenerateNewSaplingZKey(bool addToWallet) { AssertLockHeld(cs_wallet); // mapSaplingZKeyMetadata @@ -168,7 +168,7 @@ SaplingPaymentAddress CWallet::GenerateNewSaplingZKey() mapSaplingZKeyMetadata[ivk] = metadata; auto addr = xsk.DefaultAddress(); - if (!AddSaplingZKey(xsk, addr)) { + if (addToWallet && !AddSaplingZKey(xsk, addr)) { throw std::runtime_error("CWallet::GenerateNewSaplingZKey(): AddSaplingZKey failed"); } // return default sapling payment address. diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index eb350fb40..223fecb7d 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -1093,7 +1093,8 @@ public: * Sapling ZKeys */ //! Generates new Sapling key - libzcash::SaplingPaymentAddress GenerateNewSaplingZKey(); + // Sietch uses addToWallet=false + libzcash::SaplingPaymentAddress GenerateNewSaplingZKey(bool addToWallet=true); //! Adds Sapling spending key to the store, and saves it to disk bool AddSaplingZKey( const libzcash::SaplingExtendedSpendingKey &key,