Commit Graph

103 Commits

Author SHA1 Message Date
Kris Nuttycombe 010141426d
Allow selectors to require transparent coinbase 2023-03-09 13:04:17 -07:00
Kris Nuttycombe 2bc8713925
Use WalletTxBuilder for z_sendmany 2023-03-09 13:04:16 -07:00
Kris Nuttycombe 3cec519ce4 scripted-diff: Update Zcash copyrights to 2023
-BEGIN VERIFY SCRIPT-
for party in "The Zcash developers" "The Bitcoin Core developers" "Bitcoin Developers"; do
  sed -i"" -e "s#Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? $party#Copyright (c) \1-2023 $party#" COPYING
  sed -i"" -e "s#\(.*\)\([0-9]\{4\}\)\(-[0-9]\{4\}\)\, $party#\1\2-2023, $party#" contrib/debian/copyright
done

sed -i"" -e "s/define(_COPYRIGHT_YEAR, [0-9]\{4\})/define(_COPYRIGHT_YEAR, 2023)/" configure.ac
sed -i"" -e "s/#define COPYRIGHT_YEAR [0-9]\{4\}/#define COPYRIGHT_YEAR 2023/" src/clientversion.h

git grep "^// Copyright (c) .* The Zcash developers" \
  | awk -F ':' '{print $1}' \
  | xargs -I {} sed -i"" -e "s#// Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? The Zcash developers#// Copyright (c) \1-2023 The Zcash developers#" {}
-END VERIFY SCRIPT-
2023-01-23 11:31:54 -07:00
Kris Nuttycombe 9c600a5582 Factor out memo parsing from asyncrpcoperation_sendmany 2022-12-06 15:23:55 -07:00
Pieter Wuille ef5a37138e Switch blocks to a constant-space Merkle root/branch algorithm.
This switches the Merkle tree logic for blocks to one that runs in constant (small) space.
The old code is moved to tests, and a new test is added that for various combinations of
block sizes, transaction positions to compute a branch for, and mutations:
 * Verifies that the old code and new code agree for the Merkle root.
 * Verifies that the old code and new code agree for the Merkle branch.
 * Verifies that the computed Merkle branch is valid.
 * Verifies that mutations don't change the Merkle root.
 * Verifies that mutations are correctly detected.

(cherry picked from commit bitcoin/bitcoin@eece63fa72)
2022-07-08 22:24:23 +00:00
Pieter Wuille 204d0c37ab Do not store Merkle branches in the wallet.
Assume that when a wallet transaction has a valid block hash and transaction position
in it, the transaction is actually there. We're already trusting wallet data in a
much more fundamental way anyway.

To prevent backward compatibility issues, a new record is used for storing the
block locator in the wallet. Old wallets will see a wallet file synchronized up
to the genesis block, and rescan automatically.

(cherry picked from commit bitcoin/bitcoin@391dff16fe)
2022-07-08 21:03:40 +00:00
Kris Nuttycombe 71b6a59ec3 scripted-diff: Move utiltest to src/util
-BEGIN VERIFY SCRIPT-
git mv src/utiltest.h src/util/test.h
git mv src/utiltest.cpp src/util/test.cpp
sed -i -e 's/"utiltest\.h"/"util\/test\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i -e 's/ZCASH_UTILTEST_H/ZCASH_UTIL_TEST_H/g' src/util/test.h
sed -i -e 's/utiltest\.\(h\|cpp\)/util\/test\.\1/g' src/Makefile.am
-END VERIFY SCRIPT-
2022-07-06 10:25:28 -06:00
Kris Nuttycombe 9691d86047 Add a CLI flag to preferentially send V4 tx.
Since the wallet ecosystem may not be fully updated to handle
v5 transaction parsing at the point of NU5 activation, some
nodes may prefer to construct V4 transactions when not including
Orchard transaction components.

This change adds a CLI flag that allows node users to specify
that preference.
2022-05-26 07:26:38 -06:00
Kris Nuttycombe 15d1bb6ce9 scripted-diff: Add 2020-2022 copyright headers for files added/modified in 2020
-BEGIN VERIFY SCRIPT-
grep -l "Copyright" $(grep -L "The Zcash developers" $(git diff --name-only --diff-filter=ACM 6a08c225674df23f1c7f214bcb94732dba688d39..a960e896dd4c0b6d96db3d5ebbb1caa6c92a9f39 -- src/ test/ zcutil/ qa/)) | xargs -I {} sed -i"" -e "s#\(\(.*\)Copyright (c) .* The Bitcoin Core developers\)#\1\n\2Copyright (c) 2020-2022 The Zcash developers#" {}
-END VERIFY SCRIPT-
2022-05-11 17:32:39 -06:00
Kris Nuttycombe 90fc0eaa43 Add anchor depth parameter to Get*NoteWitnesses 2022-05-04 16:04:21 -06:00
sasha 6099daf8cd Port btest rpc_z_sendmany_taddr_to_sapling to gtest suite WalletRPCTests 2022-04-26 15:24:46 -07:00
sasha 6daecd9f78 Port btest rpc_z_mergetoaddress_internals to gtest suite WalletRPCTests 2022-04-26 15:24:39 -07:00
sasha fccc66d844 Port btest rpc_z_shieldcoinbase_internals to gtest suite WalletRPCTests 2022-04-26 15:24:34 -07:00
Jack Grigg c21890af8d wallet: Fix expected `listaddresses` sources in `rpc_wallet_tests` 2022-03-22 17:18:30 +00:00
Jack Grigg 65cb79e023 z_sendmany: Expand `privacyPolicy` cases
We now have a full roster of privacy policies. We can graph the
relationships between the policies; arrows point from more-private to
less-private, and each policy is permitted to reveal information covered
by all policies pointing to it (in addition to the extra information it
is permitted to reveal).

                       FullPrivacy
                            v
                   AllowRevealedAmounts
                        v           v
    AllowRevealedRecipients   ---- AllowRevealedSenders
               v             /               v
     AllowFullyTransparent <-  AllowLinkingAccountAddresses
                        v       v
                        NoPrivacy

The synthetic `LegacyCompat` policy now uses the `AllowFullyTransparent`
policy for backwards compatibility, and the `FullPrivacy` policy if the
sender or recipients involve Unified Addresses.

Closes zcash/zcash#5677.
Closes zcash/zcash#5678.
2022-03-18 02:45:23 +00:00
Jack Grigg 1505121877 z_sendmany: Replace `allowRevealedAmount` with `privacyStrategy`
This replaces the bool argument with a string argument, enabling us to
add additional privacy strategies. We also alter the default to be
backwards-compatible with existing RPC method usage, by only enabling
the strongest checks if a Unified Address is involved.

Closes zcash/zcash#5676.
2022-03-18 00:58:13 +00: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 8bc4c2aad8 Split LoadWalletTx from AddToWallet
The `CWallet::AddToWallet` method had completely divergent
behavior depending upon the value of the fFromLoadWallet
flag, and `pwalletdb` was unused when this flag was set
to `true`, so this is better represented as two distinct
methods on CWallet.
2022-03-07 19:03:00 -07:00
Jack Grigg bb4e792c84 Merge branch 'master' into feature/wallet_orchard-orchard_sendmany 2022-02-25 00:33:28 +00:00
Jack Grigg 2da0856e6f Add Orchard recipient support to the transaction builder
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2022-02-15 23:28:55 +00:00
therealyingtong 6436230562 Move SendManyRecipient to wallet.h and introduce optional ua field. 2022-02-15 09:50:00 +08:00
Larry Ruane c48e35bb66 Update z_listreceivedbyaddress to support unified addresses (5467) 2022-02-11 12:48:23 +00:00
Kris Nuttycombe bf79be2b57 Replace z_getbalanceforaddress with z_getbalanceforviewingkey 2022-02-09 16:58:55 -07:00
Kris Nuttycombe cf271473eb Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
Co-authored-by: str4d <thestr4d@gmail.com>
2022-02-07 16:52:31 -07:00
Kris Nuttycombe 1733c6bc0c Use a BIP 44 change address for change when sending from legacy t-addrs. 2022-01-27 21:29:37 -07:00
Kris Nuttycombe d17a0bb9de Merge remote-tracking branch 'upstream/master' into feature/wallet_unified_addresses 2022-01-25 20:27:33 -07:00
str4d a6f9c9c0bc Merge pull request #5458 from nuttycom/cleanup/sendmany_txbuilder
Use the transaction builder to implement z_sendmany.
2022-01-21 20:14:58 -07:00
Kris Nuttycombe a43dbb4925 Replace `HaveSpendingKeyForAddress` with checks at ZTXOSelector construction. 2022-01-19 14:37:54 -07:00
Kris Nuttycombe f850e89449 Replace the badly-named `PaymentSource` with `ZTXOSelector`
The ZTXOSelector type allows selection of previous Zcash
transaction outputs (both transparent outputs and shielded notes)
on the basis of either a (legacy) bare address, or for a
BIP-44 account.
2022-01-19 13:35:38 -07:00
Kris Nuttycombe cc392c70a6 Merge branch 'master' into feature/wallet_unified_addresses 2022-01-12 16:54:12 -07:00
Kris Nuttycombe 0ca7d49626 Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
Co-authored-by: str4d <jack@electriccoin.co>
2022-01-12 10:45:46 -07:00
Kris Nuttycombe 322aee238a Fix conditions around dust thresholds. 2022-01-11 19:40:02 -07:00
Kris Nuttycombe f9477a4499 Use transaction builder for asyncrpcoperation_sendmany.
This replaces the old implementation of asyncrpcoperation_sendmany
with one where all transaction construction is delegated to the
transaction builder. The capabilities of z_sendmany are somewhat
modified in the process:

* z_sendmany now permits sending funds from a Sprout address to
  both transparent and Sapling addresses. PRIVACY NOTE: When
  user sends a Sprout->Sapling transaction, the amount of the
  transaction is publicly revealed.
* z_sendmany no longer supports transactions sending funds into
  the Sprout pool, with the exception of change amounts when
  sending from a Sprout address.
* When sending transparent coinbase funds to a set of shielded
  addresses, the amount sent to recipients must fully consume
  the input value and no change is permitted. This is a slightly
  weaker constraint than was previously implemented; in the past,
  only a single shielded recipient was allowed.
2022-01-11 13:28:34 -07:00
Kris Nuttycombe 9702b47e2a Use libzcash::PaymentAddress instead of std::string in mergetoaddress 2022-01-07 11:49:09 -07:00
Kris Nuttycombe eb91c7869a Remove a use of KeyIO::DecodeDestination in z_shieldcoinbase 2022-01-07 11:49:09 -07:00
Kris Nuttycombe 20266ac911 Remove uses of KeyIO::DecodeDestination 2022-01-07 11:49:07 -07:00
Kris Nuttycombe b305ad2892 Remove the `InvalidEncoding` type from key & address variants.
The presence of this variant results in a situation where more
of the code than necessary needs to be aware of and handle
decoding failures. This change moves all handling of decoding
failures to the point of decoding.
2022-01-06 13:44:45 -07:00
str4d 3acc68548e
Merge pull request #5300 from LarryRuane/feature/wallet_orchard
Feature/wallet orchard UA RPCs
2021-12-20 20:31:10 +00:00
Larry Ruane f139cdc4fe Add new and modify existing Orchard RPCs, non-functional
The new RPCs aren't functional, only have argument parsing and sample
outputs, guarded by experimental -orchardwallet flag.

These changes used the tickets linked from
https://github.com/zcash/zcash/issues/5056 as a guide.
2021-12-15 16:40:23 -07:00
Kris Nuttycombe 4257abd328 Adds SaplingDiversifiableFullViewingKey
Adds SaplingDiversifiableFullViewingKey as a superclass of
SaplingExtendedFullViewingKey, and reduces the Sapling component
of UnifiedFullViewingKey to the new intermediate type. This
permits deserialization from the data that will be present
in the serialized form of the Sapling component of a UFVK.
2021-12-13 18:53:25 -07:00
Kris Nuttycombe 9202b127d0 Merge remote-tracking branch 'upstream/master' into feature/wallet_orchard 2021-11-23 18:38:07 -07:00
Dimitris Apostolou e05c1ddf8a
Fix typos 2021-11-14 16:27:09 +02:00
Kris Nuttycombe dbcdc560de Fix spurious test passage. 2021-10-29 13:38:36 -06:00
Kris Nuttycombe 477a166565 Use hardened derivation for the legacy Sapling key at the address index level. 2021-10-29 13:38:36 -06:00
Kris Nuttycombe 8bf4ec3b4a Require backup of the emergency recovery phrase.
After 4.5.2, all wallets will be populated with an emergency
recovery phrase, and all future addresses will be derived from
the associated seed. To prevent potential loss of funds, we
require that the user explicitly invoke the `walletconfirmbackup`
RPC method to verify that they have backed up this seed.
2021-10-29 13:38:36 -06:00
Kris Nuttycombe 5760a639d2 Use 0x7FFFFFFF for the legacy account ID. 2021-10-25 14:09:21 -06:00
Kris Nuttycombe e0ae5362c9 Revert change to the type of GenerateNewKey 2021-10-21 08:21:13 -06:00
Kris Nuttycombe d8d9cd129e Use legacy address for Sapling migration until UA functionality is available to the RPC tests. 2021-10-20 17:13:52 -06:00
Kris Nuttycombe ebab190fdf Replace account ID with ZIP-0032 key path in listaddresses output.
Account ID information is insufficiently granular to identify separate
pools of spend authority.
2021-10-20 13:33:47 -06:00
Kris Nuttycombe 2885ae7643 Derive transparent keys from mnemonic seed. 2021-10-19 17:51:14 -06:00