Commit Graph

107 Commits

Author SHA1 Message Date
Pieter Wuille
157a5d0d9c BIP143: Signing logic 2018-02-20 04:22:19 +00:00
Simon
072099d788 Implementation of Overwinter transaction format ZIP 202. 2018-02-16 10:10:15 -08:00
Jack Grigg
bec2235148 Cleanup: Add braces for clarity 2017-12-20 11:18:59 +00:00
Jack Grigg
9a2b8ae57f Update wallet logic to account for viewing keys
The wallet code previously assumed that an unlocked wallet would always
have a spending key associated with a note decryptor. Viewing keys break
this assumption.
2017-12-20 00:46:37 +00:00
Jack Grigg
167cd33374 Implement viewing key storage in the wallet 2017-12-20 00:46:37 +00:00
Jack Grigg
642a1caf93 ViewingKey -> ReceivingKey per zcash/zips#117 2017-12-04 17:17:18 +00:00
Simon
9e84b5aa0d Check mempooltxinputlimit when creating a transaction to avoid local
mempool rejection.
2017-06-17 14:41:25 -07:00
zkbot
a7cf698873 Auto merge of #2100 - str4d:2074-rpc, r=arcalinea
Bitcoin 0.12 RPC PRs 1

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6266
- bitcoin/bitcoin#6257
- bitcoin/bitcoin#6271
- bitcoin/bitcoin#6158
- bitcoin/bitcoin#6307
- bitcoin/bitcoin#6290
- bitcoin/bitcoin#6262
- bitcoin/bitcoin#6088
- bitcoin/bitcoin#6339
- bitcoin/bitcoin#6299 (partial, remainder in #2099)
- bitcoin/bitcoin#6350
- bitcoin/bitcoin#6247
- bitcoin/bitcoin#6362
- bitcoin/bitcoin#5486
- bitcoin/bitcoin#6417
- bitcoin/bitcoin#6398 (partial, remainder was included in #1950)
- bitcoin/bitcoin#6444
- bitcoin/bitcoin#6456 (partial, remainder was included in #2082)
- bitcoin/bitcoin#6380
- bitcoin/bitcoin#6970

Part of #2074.
2017-03-04 02:57:46 +00:00
Philip Kaufmann
db954a65ac use const references where appropriate 2017-03-03 10:57:05 -08:00
Matt Corallo
aa30f65502 Add FundTransaction method to wallet
Some code stolen from Jonas Schnelli <jonas.schnelli@include7.ch>
2017-03-02 13:23:03 -08:00
zkbot
dff700c1af Auto merge of #2055 - str4d:1545-note-decryption-error-class, r=daira
Use a more specific exception class for note decryption failure

Closes #1545.
2017-02-08 03:12:37 +00:00
Jack Grigg
51fde9ea08 Use a more specific exception class for note decryption failure
Closes #1545.
2017-01-31 23:05:19 +01:00
Jack Grigg
207924a1d5 Remove OpenSSL PRNG reseeding
Per https://download.libsodium.org/doc/generating_random_data/ reseeding the
default libsodium PRNG is not required.
2017-01-23 17:06:54 +01:00
Jack Grigg
c0ec0e756b Fix bug in IncrementNoteWitness() 2016-12-13 22:53:52 +13:00
Jack Grigg
6f78f4f44c Only check cache validity for witnesses being incremented or decremented
Fixes the bug resulting from #1904.
2016-12-13 09:34:55 +13:00
Jack Grigg
9d2cc3a784 Make the test pass by fixing the bug! 2016-12-10 00:56:32 +13:00
Jack Grigg
03f83b9b0d Write witness caches when writing the best block
For steady-state operation, this reduces the average time between wallet disk
writes from once per block to once per hour.

On -rescan, witness caches are only written out at the end along with the best
block, increasing speed while ensuring that on-disk state is kept consistent.

Witness caches are now never recreated during a -reindex, on the assumption that
the blocks themselves are not changing (the chain is just being reconstructed),
and so the witnesses will remain valid.

Part of #1749.
2016-11-30 14:04:37 +13:00
Jack Grigg
a4ef3aa9b5 Clear witnessHeight and nWitnessCacheSize in ClearNoteWitnessCache 2016-11-15 17:53:41 +13:00
Jack Grigg
ccfd8aae1d Add code comments about CNoteData::witnessHeight 2016-11-15 16:42:22 +13:00
Jack Grigg
4a6a48479d Copy over CNoteData::witnessHeight when updating wallet tx 2016-11-15 14:08:41 +13:00
Jack Grigg
40ef121e6a Correctly set CNoteData::witnessHeight when decrementing witness caches
Closes #1715
2016-11-15 14:08:35 +13:00
Jack Grigg
1b407cba2b Add heights to log output 2016-10-20 11:02:15 -05:00
Jack Grigg
878c4b1b50 Clear witness cache when re-witnessing notes
Closes #1378
2016-10-20 10:32:20 -05:00
Jack Grigg
b6961fc112 Increment witnesses for new transactions on rescan
Closes #1400
2016-10-17 09:55:02 -05:00
Daira Hopwood
95e32d88b0 Add another assertion about the witness cache.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2016-10-17 05:09:27 +01:00
Daira Hopwood
8e41408aa7 Add another assertion to narrow down where the bug occurs.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2016-10-17 05:09:27 +01:00
Daira Hopwood
8a7d37befd Move the increment of nWitnessCacheSize to make the later assertions correct.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2016-10-17 05:09:27 +01:00
Jack Grigg
83d7b5b67b Add more asserts to track down the bug 2016-10-17 05:09:27 +01:00
zkbot
ec8dc3a88a Auto merge of #1431 - bitcartel:master_1373_taddr_coinbase_error, r=bitcartel
Return a more informative error message when trying to spend coinbase; select non-coinbase inputs when sending to a transparent output if needed

For #1373 and #1519

Code change:
- Extra parameter added to AvailableCoins to include or exclude Coinbase coins.  Default value of parameter is 'true' as current behaviour is to include Coinbase coins.
- SelectCoins, used for sending taddr->taddr, will now exclude Coinbase coins.

Unit test:
Tried to write a test to focus on the extra parameter added to AvailableCoins but could not.

Empirical testing on Testnet:
Current behaviour is that upstream RPC commands sendfrom and sendtoaddress try to spend coinbase coins returned by AvailableCoins.  So the user will see:

```
./zcash-cli sendtoaddress mrEGRmGJhmwAa4MQjzGd86ry63vrvovu9b 1000.0
error: {"code":-6,"message":"Insufficient funds"}

./zcash-cli sendtoaddress mrEGRmGJhmwAa4MQjzGd86ry63vrvovu9b 0.00003000
error: {"code":-4,"message":"Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."}

./zcash-cli sendfrom "" mrEGRmGJhmwAa4MQjzGd86ry63vrvovu9b 0.00003000
error: {"code":-4,"message":"Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."}
```

After fix is applied:

```
./zcash-cli sendtoaddress mrEGRmGJhmwAa4MQjzGd86ry63vrvovu9b 1000.0
error: {"code":-6,"message":"Insufficient funds"}

./zcash-cli sendtoaddress mrEGRmGJhmwAa4MQjzGd86ry63vrvovu9b 0.00003000
error: {"code":-4,"message":"Coinbase funds can only be sent to a zaddr"}
```

When non-coinbase UTXOs exist, they will now be selected and used:

```
./zcash-cli z_sendmany tnPJZHeVxegCg91utaquBRPEDBGjozfz9iLDHt7zvphFbZdspNgkTVLCGjDcadQBKNyUwKs8pNjDXuEZKrE1aNLpFwHgz4t '[{"address":"mx5fTRhLZwbYE7ZqhAPueZgQGSnwTbdvKU", "amount":0.01}]'

./zcash-cli sendtoaddress mrEGRmGJhmwAa4MQjzGd86ry63vrvovu9b 1000.0
error: {"code":-6,"message":"Insufficient funds"}

./zcash-cli sendtoaddress mrEGRmGJhmwAa4MQjzGd86ry63vrvovu9b 0.00003000
9818e543ac2f689d4ce8b52087607d73fecd771d45d316a1d9db092f0485aff2

./zcash-cli sendfrom "" mrEGRmGJhmwAa4MQjzGd86ry63vrvovu9b 0.00003000
899f2894823f51f15fc73b5e0871ac943edbe0ff88e1635f86906087b72caf30
```
2016-10-16 22:08:07 -04:00
Simon
2b1cda3b6a Return improved error message when trying to spend Coinbase coins (#1373).
Extra parameter added to AvailableCoins to include or exclude Coinbase coins.
SelectCoins, used for sending taddr->taddr, will exclude Coinbase coins.

Added qa rpc test and a runtime parameter -regtestprotectcoinbase to enforce
the coinbase->zaddr consensus rule in regtest mode.
2016-10-16 19:05:56 -07:00
Jack Grigg
6e263a5fd3 Address review comments 2016-10-16 16:26:51 -05:00
Jack Grigg
a581fe2aae Only ignore runtime errors caused by failed note decryption 2016-10-14 17:16:09 -05:00
Jack Grigg
1a62587e9a Delay caching of nullifiers when wallet is locked
Closes #1502
2016-10-14 17:16:09 -05:00
zkbot
cc10005247 Auto merge of #1486 - str4d:1456-writewitnesscache-exception-safety, r=bitcartel
WriteWitnessCache: Catch errors and abort transaction

Closes #1452
2016-10-14 17:37:53 -04:00
zkbot
bb25bd4bc1 Auto merge of #1533 - bitcartel:master_1447_document_getfilterednotes, r=bitcartel
Document CWallet::GetFilteredNotes

Also fixes return type of method which should be void.

Part of #1447
2016-10-13 20:25:19 -04:00
Simon
cb0d208f6b Document CWallet::GetFilteredNotes and fix return type which should be
void.
2016-10-13 17:01:54 -07:00
Jack Grigg
e492d98632 Document CWalletTx::FindMyNotes
Part of #1447
2016-10-13 18:27:58 -05:00
Jack Grigg
82c2d97c60 Add unit tests for WriteWitnessCache
Requires moving implementation into header
2016-10-11 09:33:47 -05:00
Sean Bowe
74f15a73a1 Make 100KB transaction size limit a consensus rule, rather than a standard rule. 2016-10-08 00:00:23 -06:00
Jack Grigg
6216b4b2dc WriteWitnessCache: Catch errors and abort transaction
Closes #1456
2016-10-05 09:49:43 -05:00
zkbot
4f49d32a28 Auto merge of #1427 - bitcartel:master_1345_getbalance, r=bitcartel
Fixes #1345 so that RPC getbalance star calculates balance of UTXOs correctly.
2016-10-04 01:20:12 -04:00
Simon
86cf60b5c8 Fixes #1345 so that UTXO debit and credits are computed correctly for a transaction. 2016-10-03 11:06:43 -07:00
zkbot
d5dce9342b Auto merge of #1444 - str4d:1394-reindex-clear-witness-caches, r=str4d
Clear note witness caches on reindexing

This PR also fixes a test that was passing arguments in the wrong order.

Closes #1394
2016-09-30 02:30:01 -04:00
Simon
82bd9ee81b Fix comment and formatting per review 2016-09-29 22:07:38 -07:00
Simon
2aa9c0253a Update to use new API in CCryptoKeyStore and store a viewing key in walletdb. 2016-09-29 20:17:30 -07:00
Simon
73699ceaf6 Add support for spending keys to the encrypted wallet. 2016-09-29 20:17:30 -07:00
Jack Grigg
40600f5089 Simplify ClearNoteWitnessCache() 2016-09-30 15:00:16 +13:00
zkbot
42941c9fd4 Auto merge of #1445 - bitcartel:master_fix_filtered_notes, r=str4d
Fix casting error in GetFilteredNotes

Use int for minDepth like upstream instead of size_t which can lead to casting problems if a wallet tx has a depth of -1.
Also don't use FindMyNotes as mapNoteData has already been set on wallet tx.

@str4d As dicussed. This should be merged before other PRs related to wallet.
2016-09-29 05:33:11 -04:00
Jack Grigg
56fb1bb8e4 Write note witness cache atomically to disk to avoid corruption
Closes #1378
2016-09-28 11:51:42 +13:00
Simon
dec49d1f82 Fix GetFilteredNotes to use int for minDepth like upstream and avoid casting problems. Don't use FindMyNotes as mapNoteData has already been set on wallet tx. 2016-09-27 11:14:49 -07:00