Line data Source code
1 : // Copyright (c) 2016-2020 The Zcash developers 2 : // Copyright (c) 2020-2021 The PIVX Core developers 3 : // Distributed under the MIT software license, see the accompanying 4 : // file COPYING or https://www.opensource.org/licenses/mit-license.php . 5 : 6 : #ifndef PIVX_TEST_LIBRUST_UTILTEST_H 7 : #define PIVX_TEST_LIBRUST_UTILTEST_H 8 : 9 : #include "sapling/address.h" 10 : #include "sapling/incrementalmerkletree.h" 11 : #include "sapling/note.h" 12 : #include "sapling/noteencryption.h" 13 : #include "wallet/wallet.h" 14 : 15 18 : struct TestSaplingNote { 16 : libzcash::SaplingNote note; 17 : SaplingMerkleTree tree; 18 : }; 19 : 20 : struct ShieldedDestination { 21 : const libzcash::SaplingExtendedSpendingKey &sk; 22 : CAmount amount; 23 : }; 24 : 25 1452 : struct TransparentInput { 26 : COutPoint outPoint; 27 : CScript scriptPubKey; 28 : CAmount amount; 29 : }; 30 : 31 : 32 : libzcash::SaplingExtendedSpendingKey GetTestMasterSaplingSpendingKey(); 33 : 34 : CKey AddTestCKeyToKeyStore(CBasicKeyStore& keyStore, bool genNewKey = false); 35 : CKey AddTestCKeyToWallet(CWallet& wallet, bool genNewKey = false); 36 : 37 : /** 38 : * Generates a dummy destination script 39 : */ 40 : CScript CreateDummyDestinationScript(); 41 : 42 : /** 43 : * Generate a dummy SaplingNote and a SaplingMerkleTree with that note's commitment. 44 : */ 45 : TestSaplingNote GetTestSaplingNote(const libzcash::SaplingPaymentAddress& pa, CAmount value); 46 : 47 : 48 : /** 49 : * One or many inputs from keyStoreFrom, one or many shielded outputs to pwalletIn (if not nullptr). 50 : */ 51 : CWalletTx GetValidSaplingReceive(const Consensus::Params& consensusParams, 52 : CBasicKeyStore& keyStoreFrom, 53 : std::vector<TransparentInput> vIn, 54 : std::vector<ShieldedDestination> vDest, 55 : const CWallet* pwalletIn = nullptr); 56 : 57 : /** 58 : * Single dummy input, one or many shielded outputs. 59 : */ 60 : CWalletTx GetValidSaplingReceive(const Consensus::Params& consensusParams, 61 : CWallet& keyStoreFrom, 62 : CAmount inputAmount, 63 : std::vector<ShieldedDestination> vDest, 64 : bool genNewKey = false, 65 : const CWallet* pwalletIn = nullptr); 66 : 67 : /** 68 : * Single dummy input, single shielded output to sk default address. 69 : */ 70 : CWalletTx GetValidSaplingReceive(const Consensus::Params& consensusParams, 71 : CWallet& keyStore, 72 : const libzcash::SaplingExtendedSpendingKey &sk, 73 : CAmount value, 74 : bool genNewKey = false, 75 : const CWallet* pwalletIn = nullptr); 76 : 77 : #endif // PIVX_TEST_LIBRUST_UTILTEST_H