Skip to content

Commit

Permalink
Fix fund raw transaction rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
timemarkovqtum committed Oct 16, 2024
1 parent c9c8ac3 commit e264f63
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/wallet/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ util::Result<CreatedTransactionResult> FundTransaction(CWallet& wallet, const CM
preset_txin.SetScriptWitness(txin.scriptWitness);
}

CAmount nGasFee = wallet.GetTxGasFee(tx);
CAmount nGasFee = wallet.GetTxGasFee(vecSend);
auto res = CreateTransaction(wallet, vecSend, change_pos, coinControl, false, nGasFee);
if (!res) {
return res;
Expand Down
11 changes: 11 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5666,4 +5666,15 @@ CAmount CWallet::GetTxGasFee(const CMutableTransaction& tx)
}
return 0;
}

CAmount CWallet::GetTxGasFee(const std::vector<CRecipient>& vecSend)
{
CMutableTransaction txNew;
for (const auto& recipient : vecSend)
{
CTxOut txout(recipient.nAmount, GetScriptForDestination(recipient.dest));
txNew.vout.push_back(txout);
}
return GetTxGasFee(txNew);
}
} // namespace wallet
1 change: 1 addition & 0 deletions src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);

CAmount GetTxGasFee(const CMutableTransaction& tx);
CAmount GetTxGasFee(const std::vector<CRecipient>& vecSend);

bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
Expand Down

0 comments on commit e264f63

Please sign in to comment.