Commit Graph

107 Commits

Author SHA1 Message Date
Kris Nuttycombe 28040f9ce4 scripted-diff: Add 2016-2022 copyright headers for files added/modified in 2016
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM bitcoin-v0.11.2..94f427a211bb337200c29a1e19be0f5ad2f171b0 -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2016-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:23:09 -06:00
Kris Nuttycombe 87cc0d22db Add RecipientType to GetPaymentAddressForRecipient result.
This now returns whether or not the address corresponds to an
internal recipient, an external address for the wallet, or a
counterparty's address (an address not derived from any of
the wallet's keys) from GetPaymentAddressForRecipient.

Fixes #5708
2022-03-20 16:36:38 -06:00
Kris Nuttycombe 4df6c028f4 Correctly report change outputs in z_viewtransaction.
One of the invariants that we want to hold for unified addresses
is that we never want change addresses to be visible to users.
This updates address metadata retrieval to also indicate whether
or not an address is associated with a UFVK's internal key,
and omits and flags change addresses in z_viewtransaction output.
2022-03-18 11:09:35 -06:00
Kris Nuttycombe 9d8c20ed78 Add UnifiedAddress variant to ZTXOSelector
When a user supplies a unified address as the source of funds
for z_sendmany, the previous behavior could have risked user
privacy by spending transparent UTXOs belonging to different
diversified addresses in the same transaction, thereby linking
those addresses, and consequently any diversified shielded
receivers of unified addresses containing those transparent
receivers.

This change limits selection of transparent UTXOs to only those
explicitly associated with the unified receivers of the provided
source UA. Also, if a UA is provided as the source, the behavior
is maintained that only shielded notes in pools corresponding to
the receivers of that UA will be selected.
2022-03-17 11:38:44 -06:00
Kris Nuttycombe 258f0fc72f Add Orchard components to unified full viewing keys
Co-authored-by: Jack Grigg <jack@z.cash>
2022-02-22 21:08:10 +00:00
Kris Nuttycombe 1a1522a4f1 Add Orchard components to unified address
Co-authored-by: Jack Grigg <jack@z.cash>
2022-02-21 17:04:27 +00:00
Kris Nuttycombe bf79be2b57 Replace z_getbalanceforaddress with z_getbalanceforviewingkey 2022-02-09 16:58:55 -07:00
Kris Nuttycombe 66530d97e1 Rename AddSaplingIncomingViewingKey -> AddSaplingPaymentAddress
This operation was poorly named; the wallet already contained
the IVK, and this operation was simply adding the ability to
look up the IVK by a specific diversified address derived
from that IVK.
2022-01-30 17:24:52 -07:00
Kris Nuttycombe cc392c70a6 Merge branch 'master' into feature/wallet_unified_addresses 2022-01-12 16:54:12 -07:00
Kris Nuttycombe c35e2b4438 Remove spurious uses of HaveSpendingKeyForPaymentAddress
There's no need to dispatch through this visitor in cases where
the payment address type is already statically known.
2022-01-06 13:44:45 -07:00
Kris Nuttycombe eb53abbbaf Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2022-01-04 16:29:53 -07:00
Kris Nuttycombe 74e4bef6f2 Ensure that unified address metadata is always correctly populated.
This reworks the way that address metadata is added to the wallet
to make adding address metadata to the wallet's in-memory cache
the responsibility of a single method rather than distributed
across multiple places in the code.
2021-12-23 09:33:17 -07:00
Kris Nuttycombe 900cd50741 Rename `ZcashdUnifiedSpendingKeyMetadata` -> `ZcashdUnifiedAccount`
Also, fix a couple of minor documentation issues and
make UA generation tests a little more robust.
2021-12-22 16:09:17 -07:00
Kris Nuttycombe 24e46a16f1 Only derive ZcashdUnifiedFullViewingKey from UnifiedFullViewingKey
This changes ZcashdUnifiedSpendingKey::ToUnifiedFullViewingKey
to return a `UnifiedFullViewingKey` object. This makes the
derivation of ZcashdUnifiedFullViewingKey values more regular,
removing the need to be able to construct these values directly
from the spending key.

This change also modifies ZcashdUnifiedSpendingKey to remove
the `std::optional` wrapper from its member keys. This
optionality is spurious, because it is always possible to
derive a "complete" spending key, and we do not support
import of unified spending keys.
2021-12-22 16:09:17 -07:00
Kris Nuttycombe 0dcdc28a38 Add CWallet::GetUnifiedForReceiver 2021-12-22 15:57:47 -07:00
Kris Nuttycombe b29ca10b8d Add unified address generation.
Generate unified addresses from UFVKs, and add the associated
metadata to the wallet database.
2021-12-22 15:57:47 -07:00
Kris Nuttycombe e56f252a86 Add unified address tracking to KeyStore 2021-12-22 15:55:36 -07:00
Kris Nuttycombe ef068c51a9 Store ufvks to the wallet database. 2021-12-22 15:55:36 -07:00
Kris Nuttycombe d65200c860 Refine structure of Zcash address generation.
This commit does not include functional changes; it merely
breaks up content previously included in `zcash/address/zip32.h`
into smaller and more focused components.
2021-11-30 11:22:37 -07:00
Kris Nuttycombe 0951fe22d8 Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-10-30 08:26:59 -06:00
Kris Nuttycombe b67e62d977 Address comments from code review. 2021-10-29 13:38:36 -06:00
Kris Nuttycombe 5677649af1 Derive random HD seeds from ZIP-339 seed phrases.
Add support for dump of legacy HD seeds & persistence of mnemonic-based seeds.
2021-10-19 11:48:02 -06:00
Marko Bencun 2fd8809300 keystore GetKeys(): return result instead of writing to reference
Issue: #10905

By returning the result, a few useless lines can be removed.

Return-value-optimization means there should be no copy.

zcash: cherry picked from commit 5cb3da04b8882ca975b4e3d6c089c64bbaf67d0d
zcash: https://github.com/bitcoin/bitcoin/pull/10916
2021-04-12 17:15:22 -06:00
Jack Grigg b521cb8932 scripted-diff: Migrate from boost::variant to std::variant
-BEGIN VERIFY SCRIPT-
sed -i 's/boost::variant/std::variant/' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ;
sed -i 's/boost::get<\(.*\)>(&/std::get_if<\1>(\&/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.cpp ;
sed -i 's/boost::get</std::get</' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.cpp ;
sed -i 's/boost::apply_visitor(/std::visit(/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ;
sed -i 's/class \(.*\)\b \?: public boost::static_visitor<.*>/class \1/' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ;
sed -i ':a;N;$!ba;s/#include <boost\/variant\(\/.*\)\?.hpp>\n//' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ;
sed -i ':a;N;$!ba;s/#include "boost\/variant\/.*.hpp"\n//' ./src/*/*.cpp ;
-END VERIFY SCRIPT-
2020-12-16 22:49:53 +00:00
Jack Grigg b62bb98087 Remove default address parameter from Sapling keystore methods
Now that we store SaplingExtendedFullViewingKey internally, we have
access to the default address everywhere we require it.
2020-02-20 13:01:49 +00:00
Jack Grigg d74fdd76eb SaplingFullViewingKey -> SaplingExtendedFullViewingKey in keystore maps
All of these maps are created from scratch on wallet load, so we can
alter their contents without compatibility concerns. With this change,
we can use the existing maps to implement viewing key support. The
downside is that the wallet will take more space in memory, but that can
easily be improved in future by storing ExtFVK fingerprints in some of
the maps (which would improve memory usage even compared to the original
layout).
2020-02-20 13:01:49 +00:00
Jack Grigg 9658c87d4a Move ZIP 32 classes inside zcash/Address.hpp
This fixes the dependency graph between the general address-handling
logic, ZIP 32, and the core Sapling address classes.
2020-02-20 12:26:58 +00:00
Matt Corallo e61f62923b
Add logic to track pubkeys as watch-only, not just scripts 2019-11-14 15:46:06 +00:00
Larry Ruane 5a5094bbb5 simplify locking, merge cs_SpendingKeyStore into cs_KeyStore 2019-11-03 19:53:28 -07:00
Daira Hopwood bc909a7a7f Replace http with https: in links to the MIT license.
Also change MIT/X11 to just MIT, since no distinction was intended.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2019-07-18 15:26:01 +01:00
Jack Grigg 1b79de781c
Store ExtFVK with encrypted Sapling spending key instead of FVK
This ensures that even when the wallet is encrypted, we can derive the default
Sapling payment address for our spending keys.
2018-10-05 23:13:32 +01:00
Homu 325ba00336 Auto merge of #3542 - Eirik0:3511-update-address-mapping, r=bitcartel
Add newly discovered sapling addresses to the wallet when decrypting

Closes #3511
2018-10-03 21:49:32 -07:00
Eirik Ogilvie-Wigley a4ecd0fa72 Add newly discovered sapling addresses to the wallet 2018-10-01 09:34:25 -06:00
Eirik Ogilvie-Wigley 83c4e360da Address need not be optional when adding sapling keys 2018-09-27 15:44:04 -06:00
Eirik Ogilvie-Wigley 5e360fb29f Add sapling spending keys to z_exportwallet 2018-09-14 15:07:15 -06:00
Jack Grigg 70b4ad2dcd
wallet: Switch from SaplingSpendingKey to SaplingExtendedSpendingKey
The wallet now only stores Sapling extended spending keys, and thus can
only be used with keys generated from an HDSeed via ZIP 32.

Note that not all Sapling keys in the wallet will correspond to the
wallet's HDSeed, as a standalone Sapling xsk can be imported via
z_importkey. However, it must have been generated from a seed itself,
and thus is more likely to be backed up elsewhere.
2018-09-03 10:45:37 +01:00
Jack Grigg 70c8c25e4b
Store HDSeed in CBasicKeyStore 2018-09-03 10:27:52 +01:00
Jack Grigg 25d5e80cbe
Rename *SpendingKey -> *SproutSpendingKey
Also GetPaymentAddresses -> GetSproutPaymentAddresses
2018-08-03 10:10:26 +01:00
Jack Grigg 4c77517772
Rename *ViewingKey* -> *SproutViewingKey* 2018-08-03 02:23:38 +01:00
Jack Grigg 93fcf892d4
Rename SpendingKeyMap -> SproutSpendingKeyMap 2018-08-03 01:47:30 +01:00
Jack Grigg 5175a7f07b
Pass SaplingPaymentAddress to store through the CKeyStore 2018-08-03 01:01:45 +01:00
Jack Grigg e8a949c153
Rename CryptedSpendingKeyMap -> CryptedSproutSpendingKeyMap 2018-08-03 00:23:08 +01:00
Jack Grigg 4715b31c76
Implement CKeyStore::GetSaplingPaymentAddresses() 2018-07-30 16:01:22 +01:00
Jay Graber 2173767365 Add crypted keystore sapling add key 2018-07-05 15:00:00 -07:00
Jay Graber 8e91ebf76c Change default_address to return SaplingPaymentAddr and not boost::optional 2018-07-05 14:52:51 -07:00
Jay Graber f4207d0c0e Add SaplingIncomingViewingKeys map, SaplingFullViewingKey methods 2018-07-05 14:52:46 -07:00
Jay Graber efb7662d4a Add Sapling Add/Have/Get to keystore 2018-07-05 14:37:33 -07:00
Jack Grigg e5eab182b5
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.
2018-05-11 17:14:49 -04:00
Jack Grigg 44e37656bf
Add watch-only support to Zcash RPC methods
Balance totals do not include spends linked to viewing key addresses, as
nullifiers cannot be calculated and therefore spends cannot be detected.
2017-12-20 00:46:37 +00:00
Jack Grigg aa666c9673
Implement viewing key storage in the keystore 2017-12-04 17:17:18 +00:00