add pegin_witness to witness inputs

This commit is contained in:
Gregory Sanders 2017-09-15 14:19:13 -04:00
parent 36b3ab1a22
commit 16973cd1d2
3 changed files with 15 additions and 20 deletions

View file

@ -97,29 +97,18 @@ CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERS
CMutableTransaction::CMutableTransaction(const CTransaction& tx) : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), wit(tx.wit), nLockTime(tx.nLockTime) {}
/**
* The input witness consists of three elements, two of which are
* The input witness consists of four elements, three of which are
* optional. The optional elements have to do with asset issuance
* and are not normally present, most of the time. For this reason
* the optional elements are places in a lower branch of the Merkle
* tree. When not present, they take on constant values in the hash
* tree.
* and peg-in transactions, nor present most of the time.
*
* S : script witness
* A : issuance amount rangeproof
* I : inflation keys rangeproof
*
* .
* / \
* . S
* / \
* A I
*/
*/
uint256 CTxInWitness::GetHash() const
{
std::vector<uint256> leaves;
leaves.push_back(SerializeHash(vchIssuanceAmountRangeproof, SER_GETHASH, 0));
leaves.push_back(SerializeHash(vchInflationKeysRangeproof, SER_GETHASH, 0));
leaves.push_back(SerializeHash(scriptWitness.stack, SER_GETHASH, 0));
leaves.push_back(SerializeHash(m_pegin_witness.stack, SER_GETHASH, 0));
return ComputeFastMerkleRoot(leaves);
}

View file

@ -509,9 +509,12 @@ public:
class CTxInWitness
{
public:
// TODO generalize CScriptWitness into just CWitness
std::vector<unsigned char> vchIssuanceAmountRangeproof;
std::vector<unsigned char> vchInflationKeysRangeproof;
CScriptWitness scriptWitness;
// Re-use script witness struct to include its own witness
CScriptWitness m_pegin_witness;
ADD_SERIALIZE_METHODS;
@ -521,19 +524,21 @@ public:
READWRITE(vchIssuanceAmountRangeproof);
READWRITE(vchInflationKeysRangeproof);
READWRITE(scriptWitness.stack);
READWRITE(m_pegin_witness.stack);
}
CTxInWitness() { }
bool IsNull() const
{
return vchIssuanceAmountRangeproof.empty() && vchInflationKeysRangeproof.empty() && scriptWitness.IsNull();
return vchIssuanceAmountRangeproof.empty() && vchInflationKeysRangeproof.empty() && scriptWitness.IsNull() && m_pegin_witness.IsNull();
}
void SetNull()
{
vchIssuanceAmountRangeproof.clear();
vchInflationKeysRangeproof.clear();
scriptWitness.stack.clear();
m_pegin_witness.stack.clear();
}
uint256 GetHash() const;

File diff suppressed because one or more lines are too long