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:
@@ -19,12 +19,12 @@ class JSInput {
|
||||
public:
|
||||
ZCIncrementalWitness witness;
|
||||
SproutNote note;
|
||||
SpendingKey key;
|
||||
SproutSpendingKey key;
|
||||
|
||||
JSInput();
|
||||
JSInput(ZCIncrementalWitness witness,
|
||||
SproutNote note,
|
||||
SpendingKey key) : witness(witness), note(note), key(key) { }
|
||||
SproutSpendingKey key) : witness(witness), note(note), key(key) { }
|
||||
|
||||
uint256 nullifier() const {
|
||||
return note.nullifier(key);
|
||||
@@ -33,12 +33,12 @@ public:
|
||||
|
||||
class JSOutput {
|
||||
public:
|
||||
PaymentAddress addr;
|
||||
SproutPaymentAddress addr;
|
||||
uint64_t value;
|
||||
boost::array<unsigned char, ZC_MEMO_SIZE> memo = {{0xF6}}; // 0xF6 is invalid UTF8 as per spec, rest of array is 0x00
|
||||
|
||||
JSOutput();
|
||||
JSOutput(PaymentAddress addr, uint64_t value) : addr(addr), value(value) { }
|
||||
JSOutput(SproutPaymentAddress addr, uint64_t value) : addr(addr), value(value) { }
|
||||
|
||||
SproutNote note(const uint252& phi, const uint256& r, size_t i, const uint256& h_sig) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user