privatesend: Avoid interacting with keypool in CTransactionBuilder ctor (#3723)

This commit is contained in:
UdjinM6 2020-09-21 14:20:10 +03:00 committed by pasta
parent f601122cbd
commit a198a74a4f
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -123,11 +123,17 @@ CTransactionBuilder::CTransactionBuilder(CWallet* pwalletIn, const CompactTallyI
}
// Create dummy tx to calculate the exact required fees upfront for accurate amount and fee calculations
CMutableTransaction dummyTx;
// Get a comparable dummy scriptPubKey
CTransactionBuilderOutput dummyOutput(this, pwallet, 0);
CScript dummyScript = dummyOutput.GetScript();
dummyOutput.ReturnKey();
// And create dummy signatures for all inputs
// Get a comparable dummy scriptPubKey, avoid writting/flushing to the actual wallet db
CScript dummyScript;
{
LOCK(pwallet->cs_wallet);
WalletBatch dummyBatch(pwallet->GetDBHandle(), "r+", false);
dummyBatch.TxnBegin();
CPubKey dummyPubkey = pwallet->GenerateNewKey(dummyBatch, 0, false);
dummyBatch.TxnAbort();
dummyScript = ::GetScriptForDestination(dummyPubkey.GetID());
}
// Create dummy signatures for all inputs
SignatureData dummySignature;
ProduceSignature(DummySignatureCreator(pwallet), dummyScript, dummySignature);
for (auto out : tallyItem.vecOutPoints) {