Skip to content

Commit

Permalink
add pegin_witness to witness inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Nov 6, 2017
1 parent 36b3ab1 commit 16973cd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
19 changes: 4 additions & 15 deletions src/primitives/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 6 additions & 1 deletion src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,12 @@ class CTxIn
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;

Expand All @@ -521,19 +524,21 @@ class CTxInWitness
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;
Expand Down
Loading

0 comments on commit 16973cd

Please sign in to comment.