]> Git Repo - VerusCoin.git/blame - doc/shield-coinbase.md
Merge remote-tracking branch 'origin/dev' into CI
[VerusCoin.git] / doc / shield-coinbase.md
CommitLineData
f4f064bb
S
1# Shielding Coinbase UTXOs
2
3**Summary**
4
43f5d521 5Use `z_shieldcoinbase` RPC call to shield coinbase UTXOs.
f4f064bb
S
6
7**Who should read this document**
8
9Miners, Mining pools, Online wallets
10
11## Background
12
13The current Zcash protocol includes a consensus rule that coinbase rewards must be sent to a shielded address.
14
15## User Experience Challenges
16
43f5d521 17A user can use the z_sendmany RPC call to shield coinbase funds, but the call was not designed for sweeping up many UTXOs, and offered a suboptimal user experience.
f4f064bb
S
18
19If customers send mining pool payouts to their online wallet, the service provider must sort through UTXOs to correctly determine the non-coinbase UTXO funds that can be withdrawn or transferred by customers to another transparent address.
20
21## Solution
22
43f5d521 23The z_shieldcoinbase call makes it easy to sweep up coinbase rewards from multiple coinbase UTXOs across multiple coinbase reward addresses.
f4f064bb
S
24
25 z_shieldcoinbase fromaddress toaddress (fee) (limit)
26
43f5d521 27The default fee is 0.0010000 ZEC and the default limit on the maximum number of UTXOs to shield is 50.
f4f064bb
S
28
29## Examples
30
43f5d521 31Sweep up coinbase UTXOs from a transparent address you use for mining:
f4f064bb
S
32
33 zcash-cli z_shieldcoinbase tMyMiningAddress zMyPrivateAddress
34
43f5d521 35Sweep up coinbase UTXOs from multiple transparent addresses to a shielded address:
f4f064bb
S
36
37 zcash-cli z_shieldcoinbase "*" zMyPrivateAddress
38
39Sweep up with a fee of 1.23 ZEC:
40
41 zcash-cli z_shieldcoinbase tMyMiningAddress zMyPrivateAddress 1.23
42
43f5d521 43Sweep up with a fee of 0.1 ZEC and set limit on the maximum number of UTXOs to shield at 25:
f4f064bb
S
44
45 zcash-cli z_shieldcoinbase "*" zMyPrivateAddress 0.1 25
46
47### Asynchronous Call
48
49The `z_shieldcoinbase` RPC call is an asynchronous call, so you can queue up multiple operations.
50
51When you invoke
52
53 zcash-cli z_shieldcoinbase tMyMiningAddress zMyPrivateAddress
54
55JSON will be returned immediately, with the following data fields populated:
56
57- operationid: a temporary id to use with `z_getoperationstatus` and `z_getoperationresult` to get the status and result of the operation.
43f5d521
S
58- shieldedUTXOs: number of coinbase UTXOs being shielded
59- shieldedValue: value of coinbase UTXOs being shielded.
60- remainingUTXOs: number of coinbase UTXOs still available for shielding.
61- remainingValue: value of coinbase UTXOs still available for shielding
f4f064bb
S
62
63### Locking UTXOs
64
65The `z_shieldcoinbase` call will lock any selected UTXOs. This prevents the selected UTXOs which are already queued up from being selected for any other send operation. If the `z_shieldcoinbase` call fails, any locked UTXOs are unlocked.
66
67You can use the RPC call `lockunspent` to see which UTXOs have been locked. You can also use this call to unlock any UTXOs in the event of an unexpected system failure which leaves UTXOs in a locked state.
68
69### Limits, Performance and Transaction Confirmation
70
43f5d521 71The number of coinbase UTXOs selected for shielding can be adjusted by setting the limit parameter. The default value is 50.
f4f064bb
S
72
73If the limit parameter is set to zero, the zcashd `mempooltxinputlimit` option will be used instead, where the default value for `mempooltxinputlimit` is zero, which means no limit.
74
75Any limit is constrained by a hard limit due to the consensus rule defining a maximum transaction size of 100,000 bytes.
76
43f5d521 77In general, the more UTXOs that are selected, the longer it takes for the transaction to be verified. Due to the quadratic hashing problem, some miners use the `mempooltxinputlimit` option to reject transactions with a large number of UTXO inputs.
f4f064bb
S
78
79Currently, as of November 2017, there is no commonly agreed upon limit, but as a rule of thumb (a form of emergent consensus) if a transaction has less than 100 UTXO inputs, the transaction will be mined promptly by the majority of mining pools, but if it has many more UTXO inputs, such as 500, it might take several days to be mined by a miner who has higher or no limits.
80
81### Anatomy of a z_shieldcoinbase transaction
82
83The transaction created is a shielded transaction. It consists of a single joinsplit, which consumes coinbase UTXOs as input, and deposits value at a shielded address, minus any fee.
84
85The number of coinbase UTXOs is determined by a user configured limit.
86
43f5d521 87If no limit is set (in the case when limit parameter and `mempooltxinputlimit` options are set to zero) the behaviour of z_shieldcoinbase is to consume as many UTXOs as possible, with `z_shieldcoinbase` constructing a transaction up to the size limit of 100,000 bytes.
f4f064bb
S
88
89As a result, the maximum number of inputs that can be selected is:
90
43f5d521
S
91- P2PKH coinbase UTXOs ~ 662
92- 2-of-3 multisig P2SH coinbase UTXOs ~ 244.
f4f064bb 93
43f5d521 94Here is an example of using `z_shieldcoinbase` on testnet to shield multi-sig coinbase UTXOs.
f4f064bb
S
95
96- Block 141042 is almost ~2 MB in size (the maximum size for a block) and contains 1 coinbase reward transaction and 20 transactions, each indivually created by a call to z_shieldcoinbase.
97 - https://explorer.testnet.z.cash/block/0050552a78e97c89f666713c8448d49ad1d7263274422272696187dedf6c0d03
98- Drilling down into a transaction, you can see there is one joinsplit, with 244 inputs (vin) and 0 outputs (vout).
99 - https://explorer.testnet.z.cash/tx/cf4f3da2e434f68b6e361303403344e22a9ff9a8fda9abc180d9520d0ca6527d
100
101
This page took 0.034246 seconds and 4 git commands to generate.