Auto merge of #3567 - bitcartel:3546_estimate_tx_size, r=bitcartel

For #3546. Improve estimated tx size for Sapling outputs.
This commit is contained in:
Homu 2018-10-05 20:33:38 -07:00
commit 72f6925de1
1 changed files with 11 additions and 7 deletions

View File

@ -3786,14 +3786,18 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
// Depending on the input notes, the actual tx size may turn out to be larger and perhaps invalid.
size_t txsize = 0;
for (int i = 0; i < zaddrRecipients.size(); i++) {
// TODO Check whether the recipient is a Sprout or Sapling address
JSDescription jsdesc;
if (mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION)) {
jsdesc.proof = GrothProof();
auto address = std::get<0>(zaddrRecipients[i]);
auto res = DecodePaymentAddress(address);
bool toSapling = boost::get<libzcash::SaplingPaymentAddress>(&res) != nullptr;
if (toSapling) {
mtx.vShieldedOutput.push_back(OutputDescription());
} else {
JSDescription jsdesc;
if (mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION)) {
jsdesc.proof = GrothProof();
}
mtx.vjoinsplit.push_back(jsdesc);
}
mtx.vjoinsplit.push_back(jsdesc);
}
CTransaction tx(mtx);
txsize += GetSerializeSize(tx, SER_NETWORK, tx.nVersion);