Skip to content

Commit

Permalink
rfc4 base
Browse files Browse the repository at this point in the history
  • Loading branch information
backpacker69 committed May 1, 2019
1 parent dff1cc4 commit f8e2c51
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/primitives/transaction.h
Expand Up @@ -192,12 +192,16 @@ struct CMutableTransaction;
/**
* Basic transaction serialization format:
* - int32_t nVersion
* - if (nVersion == 1):
* - uint32_t nTime
* - std::vector<CTxIn> vin
* - std::vector<CTxOut> vout
* - uint32_t nLockTime
*
* Extended transaction serialization format:
* - int32_t nVersion
* - if (nVersion == 1):
* - uint32_t nTime
* - unsigned char dummy = 0x00
* - unsigned char flags (!= 0)
* - std::vector<CTxIn> vin
Expand All @@ -211,7 +215,8 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);

s >> tx.nVersion;
s >> tx.nTime;
if (tx.nVersion == 1)
s >> tx.nTime;
unsigned char flags = 0;
tx.vin.clear();
tx.vout.clear();
Expand Down Expand Up @@ -247,7 +252,8 @@ inline void SerializeTransaction(const TxType& tx, Stream& s) {
const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);

s << tx.nVersion;
s << tx.nTime;
if (tx.nVersion == 1)
s << tx.nTime;
unsigned char flags = 0;
// Consistency check
if (fAllowWitness) {
Expand Down
9 changes: 6 additions & 3 deletions src/script/interpreter.cpp
Expand Up @@ -1135,8 +1135,10 @@ class CTransactionSignatureSerializer {
void Serialize(S &s) const {
// Serialize nVersion
::Serialize(s, txTo.nVersion);
// Serialize nTime
::Serialize(s, txTo.nTime);
if (txTo.nVersion == 1) {
// Serialize nTime
::Serialize(s, txTo.nTime);
}
// Serialize vin
unsigned int nInputs = fAnyoneCanPay ? 1 : txTo.vin.size();
::WriteCompactSize(s, nInputs);
Expand Down Expand Up @@ -1220,7 +1222,8 @@ uint256 SignatureHash(const CScript& scriptCode, const CTransaction& txTo, unsig
// Version
ss << txTo.nVersion;
// nTime
ss << txTo.nTime;
if (txTo.nVersion == 1)
ss << txTo.nTime;
// Input prevouts/nSequence (none/all, depending on flags)
ss << hashPrevouts;
ss << hashSequence;
Expand Down

0 comments on commit f8e2c51

Please sign in to comment.