Skip to content

Commit

Permalink
Merge #1027: Fail funded send TXs with more outputs than expected
Browse files Browse the repository at this point in the history
5a35c60 Fail funded send TXs with more outputs than expected (Bushstar)

Pull request description:

Tree-SHA512: c3847f800c45fb061d5ae526897f5bc24863c05a39b96d1c0f54bcb6bc06e06c8ecf0b0d37d8d00c9d06b8b78f07ed5f5a36a706520fd22e9680c88d8ef73753
  • Loading branch information
dexX7 committed Oct 15, 2019
2 parents 43d5f03 + 5a35c60 commit c3875d6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/omnicore/wallettxbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,12 @@ int CreateFundedTransaction(
return MP_ENCODING_ERROR;
}

// Maximum number of expected outputs
std::vector<CTxOut>::size_type max_outputs = 2;

// add reference output, if there is one
if (!receiverAddress.empty() && receiverAddress != feeAddress) {
max_outputs = 3;
CScript scriptPubKey = GetScriptForDestination(DecodeDestination(receiverAddress));
vecSend.push_back(std::make_pair(scriptPubKey, OmniGetDustThreshold(scriptPubKey)));
}
Expand Down Expand Up @@ -249,6 +253,13 @@ int CreateFundedTransaction(
strFailReason = "send to self without change";
}

if (wtxNew->get().vout.size() > max_outputs)
{
strFailReason = "more outputs than expected";
PrintToLog("%s: ERROR: more outputs than expected (Max expected %d, actual %d)\n Failed transaction: %s\n",
__func__, max_outputs, wtxNew->get().vout.size(), wtxNew->get().ToString());
}

// to restore the original order of inputs, create a new transaction and add
// inputs and outputs step by step
CMutableTransaction tx;
Expand Down

0 comments on commit c3875d6

Please sign in to comment.