update SignatureHash according to Overwinter spec

with help from str4d
This commit is contained in:
Ariel
2018-01-17 12:48:10 +02:00
committed by Jack Grigg
parent 132dc81f7d
commit 7245f32835
3 changed files with 67 additions and 24 deletions

View File

@@ -383,12 +383,7 @@ public:
*const_cast<bool*>(&fOverwintered) = header >> 31;
*const_cast<int32_t*>(&this->nVersion) = header & 0x7FFFFFFF;
} else {
// When serializing v1 and v2, the 4 byte header is nVersion
uint32_t header = this->nVersion;
// When serializing Overwintered tx, the 4 byte header is the combination of fOverwintered and nVersion
if (fOverwintered) {
header |= 1 << 31;
}
uint32_t header = GetHeader();
READWRITE(header);
}
nVersion = this->nVersion;
@@ -428,6 +423,16 @@ public:
return hash;
}
uint32_t GetHeader() const {
// When serializing v1 and v2, the 4 byte header is nVersion
uint32_t header = this->nVersion;
// When serializing Overwintered tx, the 4 byte header is the combination of fOverwintered and nVersion
if (fOverwintered) {
header |= 1 << 31;
}
return header;
}
// Return sum of txouts.
CAmount GetValueOut() const;
// GetValueIn() is a method on CCoinsViewCache, because