Commit Graph

87 Commits

Author SHA1 Message Date
Jack Grigg 2eeb6bebde
Randomize JoinSplits in z_sendmany 2016-10-18 10:41:30 -05: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
Simon 438d1e45be Use -debug=zrpc for z_* rpc calls (#1504) 2016-10-12 15:46:24 -07:00
Simon b11bb0e26a Replace GetTxid() with GetHash() 2016-09-08 21:54:34 -07:00
Simon e79ded8a47 Remove line of commented out code we don't need 2016-09-08 21:46:15 -07:00
Simon dfc0080d06 Update comment with ticket issue number 2016-09-08 21:46:15 -07:00
Simon 1eb8789789 Add assert 2016-09-08 21:46:15 -07:00
Simon ed42053a6c Fix formatting 2016-09-08 21:46:15 -07:00
Simon 2ad0b7bfe2 Use zcash constants 2016-09-08 21:46:15 -07:00
Simon b99d4f9b17 Improve error reporting when attempting to spend coinbase utxos. 2016-09-08 21:46:15 -07:00
Simon 9fb18458e8 Add assert for two mutually exclusive member variables. 2016-09-08 21:46:15 -07:00
Simon cc59ac12a9 Add ticket number to issues raised in comment. 2016-09-08 21:46:15 -07:00
Simon 00edda4ac6 Remove unused varible. 2016-09-08 21:46:15 -07:00
Simon a101ef7979 Update log statement to include fee. 2016-09-08 21:46:15 -07:00
Simon 1b141933e5 Rename GetUnspentNotes to GetFilteredNotes
Added parameter to ignore spent notes, which is true by default.
2016-09-08 21:46:15 -07:00
Simon fc46069e81 Add more logging. 2016-09-08 21:46:14 -07:00
Simon a9743bc8bf Refactor async sendmany and getbalance calls to use GetUnspentNotes(). 2016-09-08 21:46:14 -07:00
Simon 269310ce3c Replace zcashParams_ with global. 2016-09-08 21:46:14 -07:00
Simon 5f8118c8a4 Revert "Reduce use of global pzcashParams with private member variable"
This reverts commit 4d71ba58d37eb4f93d68b5e437086ce14fb24825.
2016-09-08 21:46:14 -07:00
Simon 4b32c16ba5 Reduce use of global pzcashParams with private member variable 2016-09-08 21:46:14 -07:00
Simon 485145ea78 Disable proof generation when testmode is enabled in async SendMany operation. 2016-09-08 21:46:14 -07:00
Simon 4cff8a5c50 Fix typo in error message 2016-09-08 21:46:14 -07:00
Simon 9bb6162626 Add extra checking of memo data in hexadecimal string format. 2016-09-08 21:46:14 -07:00
Simon a5905772c8 Add logging under the category "asyncrpc". 2016-09-08 21:46:14 -07:00
Simon 39c7f954d0 Remove redundant call. 2016-09-08 21:46:14 -07:00
Simon 15c83ac6b4 Remove redundant check when getting spending key for a payment address. 2016-09-08 21:46:14 -07:00
Simon 87f7c98795 Refactor to use wallet note tracking from commit a72379 2016-09-08 21:46:14 -07:00
Simon c93d8bdf9c Fix bug where call to sign and send a transaction was in wrong scope. 2016-09-08 21:46:14 -07:00
Simon 3fd5a615ac Coinbase utxos can only be spent when sending to a single zaddr.
Change from the transaction will be sent to the same zaddr.
2016-09-08 21:46:14 -07:00
Simon 14af21e9f7 Add chaining of JoinSplits within a transaction. 2016-09-08 21:46:13 -07:00
Simon 3b54bf5813 Refactoring and small improvements to async rpc operations.
Added AsyncRPCQueue::closeAndWait() so rpcserver can block on worker threads when shutting down.
AsyncRPCOperation is no longer copyable - copy constructor and assignment operators now private.
Refactoring: renamed methods, renamed member variables
Tidy up: comments, const, size_t, braces
2016-09-08 21:46:13 -07:00
Simon 15d345466d Successful result of z_sendmany returns txid so it doesn't need to return raw hex. 2016-09-08 21:46:13 -07:00
Simon b7d7b2ad9d z_sendmany from a taddr now routes change to a new address instead of back to the sender's taddr, 2016-09-08 21:46:13 -07:00
Simon 4876de6c6d Update find_unspent_notes() as mapNoteAddrs_t has been replaced by mapNoteData_t. 2016-09-08 21:46:13 -07:00
Simon dafb81614b Implement z_sendmany RPC call.
Simple implementation does not try to optimize coin or note selection.
Caller can send from a taddr or zaddr to multiple recipients.
Currently only one of the recipients can be a zaddr.
2016-09-08 21:46:13 -07:00
Simon fc72c078be Add async RPC queue and operation classes.
Add z_getoperationstatus RPC command.
Add z_sendmany RPC command (dummy implementation, does not send actual
coins).
2016-09-08 21:46:13 -07:00