Merge pull request #6572 from sellout/wallet_tx_builder-z_shieldcoinbase

Minor improvements to z_shieldcoinbase
This commit is contained in:
Kris Nuttycombe 2023-04-17 21:28:07 -06:00 committed by GitHub
commit 786d8e32e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 9 deletions

View File

@ -61,14 +61,14 @@ AsyncRPCOperation_shieldcoinbase::AsyncRPCOperation_shieldcoinbase(
assert(ztxoSelector.RequireSpendingKeys());
examine(toAddress_, match {
[](const CKeyID&) {
throw JSONRPCError(RPC_VERIFY_REJECTED, "Cannot shield coinbase output to a p2pkh address.");
},
[](const CScriptID&) {
throw JSONRPCError(RPC_VERIFY_REJECTED, "Cannot shield coinbase output to a p2sh address.");
},
[](const auto&) { },
});
[](const CKeyID&) {
throw JSONRPCError(RPC_VERIFY_REJECTED, "Cannot shield coinbase output to a p2pkh address.");
},
[](const CScriptID&) {
throw JSONRPCError(RPC_VERIFY_REJECTED, "Cannot shield coinbase output to a p2sh address.");
},
[](const auto&) { },
});
// Log the context info
if (LogAcceptCategory("zrpcunsafe")) {
@ -140,7 +140,9 @@ Remaining AsyncRPCOperation_shieldcoinbase::prepare(CWallet& wallet) {
unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING;
CAmount shieldingValue = 0;
CAmount remainingValue = 0;
size_t estimatedTxSize = 10000; // per ZIP 401 (https://zips.z.cash/zip-0401#specification)
// We start with the estimated size being the most largest recipient, which `MIN_TX_COST`
// approximates. This then increases as we add inputs to the tx.
size_t estimatedTxSize = MIN_TX_COST;
size_t utxoCounter = 0;
size_t numUtxos = 0;
bool maxedOutFlag = false;