Skip to content

Commit

Permalink
Added correct deserialization of amounts in contributions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Rusu committed Apr 7, 2020
1 parent 2b6d66d commit e69b5ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/script/script.h
Expand Up @@ -320,6 +320,11 @@ class CScriptNum
return m_value;
}

int64_t getint64() const
{
return m_value;
}

std::vector<unsigned char> getvch() const
{
return serialize(m_value);
Expand Down
4 changes: 2 additions & 2 deletions src/stake/staketx.cpp
Expand Up @@ -187,8 +187,8 @@ bool ParseTicketContrib(const CTransaction& tx, uint32_t txoutIndex, TicketContr

data.rewardAddr = uint160(items[contribAddrIndex]);
data.whichAddr = CScriptNum(items[contribAddrTypeIndex],false).getint();
data.contributedAmount = CScriptNum(items[contribAmountIndex], false).getint(); // CScriptNum can handle 32-byte integers; is that enough?
//data.contributedAmount = base_blob<64>(items[contribAmountIndex]).GetUint64(0); // this parses uint64 but not int64

data.contributedAmount = CScriptNum(items[contribAmountIndex], false, 8).getint64();

int fees = CScriptNum(items[contribVoteFeesIndex], false).getint();
if (fees >= 0 && fees <= TicketContribData::MaxFees)
Expand Down

0 comments on commit e69b5ed

Please sign in to comment.