From 4dcc48b8cb63d0a88bde9d32abeaf1cc6fe366d1 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 5 Oct 2018 11:16:20 -0700 Subject: [PATCH] For #3546. Improve estimated tx size for Sapling outputs. --- src/wallet/rpcwallet.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 84892543a..b85ab8f89 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -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(&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);