Skip to content

Commit

Permalink
Make dummy data specific to TX (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushstar authored Sep 10, 2021
1 parent 89de3bb commit 7620f79
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/masternodes/rpc_accounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,22 @@ UniValue accounttoutxos(const JSONRPCRequest& request) {
// dummy encode, mintingOutputsStart isn't filled
CScript scriptMeta;
{
std::vector<unsigned char> dummyMetadata(std::min((msg.balances.balances.size() * to.size()) * 40, (size_t)1024)); // heuristic to increse tx size before funding
scriptMeta << OP_RETURN << dummyMetadata;
CDataStream dummyMetadata(DfTxMarker, SER_NETWORK, PROTOCOL_VERSION);
dummyMetadata << static_cast<unsigned char>(CustomTxType::AccountToUtxos) << msg;

std::vector<unsigned char> padding(10);
for (const auto& recip : to) {
for (const auto& amount : recip.second.balances) {
if (amount.second != 0) {
CTxOut out{amount.second, recip.first, amount.first};
dummyMetadata << out << padding;
LogPrint(BCLog::ESTIMATEFEE, "%s: out size %d padding %d\n", __func__, sizeof(out), sizeof(unsigned char) * padding.size());
}
}
}

scriptMeta << OP_RETURN << ToByteVector(dummyMetadata);
LogPrint(BCLog::ESTIMATEFEE, "%s: dummyMetadata size %d\n", __func__, dummyMetadata.size());
}

int targetHeight = chainHeight(*pwallet->chain().lock()) + 1;
Expand Down

0 comments on commit 7620f79

Please sign in to comment.