Use boost::variant to represent shielded addresses and keys
libzcash::PaymentAddress has been renamed to libzcash::SproutPaymentAddress, and a new typedef boost::variant is now libzcash::PaymentAddress. Similarly for ViewingKey and SpendingKey. A new class InvalidEncoding is introduced as the default boost::variant option for each address and key type; it is used during decoding instead of boost::optional. All address and key storage functions in the wallet have been modified to refer specifically to the Sprout types, as they are used very precisely. In most other cases, the more general type is leveraged as much as possible, and we convert to the Sprout type when necessary. This will be subsequently wrapped in, or replaced with, context-specific functions once Sapling types are implemented.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include "consensus/upgrades.h"
|
||||
|
||||
CWalletTx GetValidReceive(ZCJoinSplit& params,
|
||||
const libzcash::SpendingKey& sk, CAmount value,
|
||||
const libzcash::SproutSpendingKey& sk, CAmount value,
|
||||
bool randomInputs) {
|
||||
CMutableTransaction mtx;
|
||||
mtx.nVersion = 2; // Enable JoinSplits
|
||||
@@ -62,7 +62,7 @@ CWalletTx GetValidReceive(ZCJoinSplit& params,
|
||||
}
|
||||
|
||||
libzcash::SproutNote GetNote(ZCJoinSplit& params,
|
||||
const libzcash::SpendingKey& sk,
|
||||
const libzcash::SproutSpendingKey& sk,
|
||||
const CTransaction& tx, size_t js, size_t n) {
|
||||
ZCNoteDecryption decryptor {sk.receiving_key()};
|
||||
auto hSig = tx.vjoinsplit[js].h_sig(params, tx.joinSplitPubKey);
|
||||
@@ -76,7 +76,7 @@ libzcash::SproutNote GetNote(ZCJoinSplit& params,
|
||||
}
|
||||
|
||||
CWalletTx GetValidSpend(ZCJoinSplit& params,
|
||||
const libzcash::SpendingKey& sk,
|
||||
const libzcash::SproutSpendingKey& sk,
|
||||
const libzcash::SproutNote& note, CAmount value) {
|
||||
CMutableTransaction mtx;
|
||||
mtx.vout.resize(2);
|
||||
@@ -97,12 +97,12 @@ CWalletTx GetValidSpend(ZCJoinSplit& params,
|
||||
|
||||
{
|
||||
if (note.value() > value) {
|
||||
libzcash::SpendingKey dummykey = libzcash::SpendingKey::random();
|
||||
libzcash::PaymentAddress dummyaddr = dummykey.address();
|
||||
libzcash::SproutSpendingKey dummykey = libzcash::SproutSpendingKey::random();
|
||||
libzcash::SproutPaymentAddress dummyaddr = dummykey.address();
|
||||
dummyout = libzcash::JSOutput(dummyaddr, note.value() - value);
|
||||
} else if (note.value() < value) {
|
||||
libzcash::SpendingKey dummykey = libzcash::SpendingKey::random();
|
||||
libzcash::PaymentAddress dummyaddr = dummykey.address();
|
||||
libzcash::SproutSpendingKey dummykey = libzcash::SproutSpendingKey::random();
|
||||
libzcash::SproutPaymentAddress dummyaddr = dummykey.address();
|
||||
libzcash::SproutNote dummynote(dummyaddr.a_pk, (value - note.value()), uint256(), uint256());
|
||||
tree.append(dummynote.cm());
|
||||
dummyin = libzcash::JSInput(tree.witness(), dummynote, dummykey);
|
||||
|
||||
Reference in New Issue
Block a user