fix(zcoin): add locked notes support for withdrawals
Past PR #2331 added support for unconfirmed notes handling to prevent spent notes reuse and show unconfirmed change notes as unspendable balance. To implement that, PR 2331 added a locked notes DB.
However, that PR added support only for swap transactions, so if a withdrawal is called before or during a swap (while spent notes are not confirmed yet) errors like 18: bad-txns-joinsplit-requirements-not-met may occur when withdrawal and swap transactions are sent to the chain.
This PR adds support for the locked notes DB for zcoin withdrawals as well. The init_withdraw RPC now returns array of rseeds values which are used to access the locked notes DB. Also the init_withdraw RPC returns received_by_me decimal amount which is used to store change value in the locked notes DB. Both rseeds and received_by_me values should be passed along with the transaction in hex to the RPC sending the transaction into the network.
Breaking change
To send zcoin transaction into the network a new z_send_raw_transaction RPC must be used, instead of the old "send_raw_transaction". The z_send_raw_transaction RPC has more parameters:
curl --url "http://127.0.0.1:7783" --data '{
"userpass": "...",
"mmrpc":"2.0",
"id": 0,
"method": "z_send_raw_transaction",
"params": {
"coin": "ZOMBIE",
"rseeds": [ "0x123..ab4", "0xbcd..789" ],
"received_by_me": "123456.7890",
"tx_hex": "0xabc..123"
}
}'
The "rseeds", "received_by_me", "tx_hex" fields are returned by init_withdraw RPC.
TODO:
Will we ever support ZIP 32? For future support we could add AccountId field into the locked notes DB.