]> Git Repo - VerusCoin.git/blobdiff - src/utiltest.cpp
Refactoring: SproutNote member variable value moved to BaseNote.
[VerusCoin.git] / src / utiltest.cpp
index 5cebc1a5dd6523434d9682cea717e42f57cc4848..60af4f7dd30a61d2fe5e14bcef408fa6ca04e02f 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "utiltest.h"
 
+#include "consensus/upgrades.h"
+
 CWalletTx GetValidReceive(ZCJoinSplit& params,
                           const libzcash::SpendingKey& sk, CAmount value,
                           bool randomInputs) {
@@ -36,7 +38,7 @@ CWalletTx GetValidReceive(ZCJoinSplit& params,
         libzcash::JSOutput(sk.address(), value)
     };
 
-    boost::array<libzcash::Note, 2> output_notes;
+    boost::array<libzcash::SproutNote, 2> output_notes;
 
     // Prepare JoinSplits
     uint256 rt;
@@ -45,9 +47,10 @@ CWalletTx GetValidReceive(ZCJoinSplit& params,
     mtx.vjoinsplit.push_back(jsdesc);
 
     // Empty output script.
+    uint32_t consensusBranchId = SPROUT_BRANCH_ID;
     CScript scriptCode;
     CTransaction signTx(mtx);
-    uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL);
+    uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId);
 
     // Add the signature
     assert(crypto_sign_detached(&mtx.joinSplitSig[0], NULL,
@@ -60,10 +63,10 @@ CWalletTx GetValidReceive(ZCJoinSplit& params,
     return wtx;
 }
 
-libzcash::Note GetNote(ZCJoinSplit& params,
+libzcash::SproutNote GetNote(ZCJoinSplit& params,
                        const libzcash::SpendingKey& sk,
                        const CTransaction& tx, size_t js, size_t n) {
-    ZCNoteDecryption decryptor {sk.viewing_key()};
+    ZCNoteDecryption decryptor {sk.receiving_key()};
     auto hSig = tx.vjoinsplit[js].h_sig(params, tx.joinSplitPubKey);
     auto note_pt = libzcash::NotePlaintext::decrypt(
         decryptor,
@@ -76,7 +79,7 @@ libzcash::Note GetNote(ZCJoinSplit& params,
 
 CWalletTx GetValidSpend(ZCJoinSplit& params,
                         const libzcash::SpendingKey& sk,
-                        const libzcash::Note& note, CAmount value) {
+                        const libzcash::SproutNote& note, CAmount value) {
     CMutableTransaction mtx;
     mtx.vout.resize(2);
     mtx.vout[0].nValue = value;
@@ -95,14 +98,14 @@ CWalletTx GetValidSpend(ZCJoinSplit& params,
     libzcash::JSInput dummyin;
 
     {
-        if (note.value > value) {
+        if (note.value() > value) {
             libzcash::SpendingKey dummykey = libzcash::SpendingKey::random();
             libzcash::PaymentAddress dummyaddr = dummykey.address();
-            dummyout = libzcash::JSOutput(dummyaddr, note.value - value);
-        } else if (note.value < value) {
+            dummyout = libzcash::JSOutput(dummyaddr, note.value() - value);
+        } else if (note.value() < value) {
             libzcash::SpendingKey dummykey = libzcash::SpendingKey::random();
             libzcash::PaymentAddress dummyaddr = dummykey.address();
-            libzcash::Note dummynote(dummyaddr.a_pk, (value - note.value), uint256(), uint256());
+            libzcash::SproutNote dummynote(dummyaddr.a_pk, (value - note.value()), uint256(), uint256());
             tree.append(dummynote.cm());
             dummyin = libzcash::JSInput(tree.witness(), dummynote, dummykey);
         }
@@ -120,7 +123,7 @@ CWalletTx GetValidSpend(ZCJoinSplit& params,
         libzcash::JSOutput() // dummy output
     };
 
-    boost::array<libzcash::Note, 2> output_notes;
+    boost::array<libzcash::SproutNote, 2> output_notes;
 
     // Prepare JoinSplits
     uint256 rt = tree.root();
@@ -129,9 +132,10 @@ CWalletTx GetValidSpend(ZCJoinSplit& params,
     mtx.vjoinsplit.push_back(jsdesc);
 
     // Empty output script.
+    uint32_t consensusBranchId = SPROUT_BRANCH_ID;
     CScript scriptCode;
     CTransaction signTx(mtx);
-    uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL);
+    uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId);
 
     // Add the signature
     assert(crypto_sign_detached(&mtx.joinSplitSig[0], NULL,
This page took 0.0272790000000001 seconds and 4 git commands to generate.