Skip to content

Commit 16973cd

Browse files
committed
add pegin_witness to witness inputs
1 parent 36b3ab1 commit 16973cd

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

src/primitives/transaction.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,18 @@ CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERS
9797
CMutableTransaction::CMutableTransaction(const CTransaction& tx) : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), wit(tx.wit), nLockTime(tx.nLockTime) {}
9898

9999
/**
100-
* The input witness consists of three elements, two of which are
100+
* The input witness consists of four elements, three of which are
101101
* optional. The optional elements have to do with asset issuance
102-
* and are not normally present, most of the time. For this reason
103-
* the optional elements are places in a lower branch of the Merkle
104-
* tree. When not present, they take on constant values in the hash
105-
* tree.
102+
* and peg-in transactions, nor present most of the time.
106103
*
107-
* S : script witness
108-
* A : issuance amount rangeproof
109-
* I : inflation keys rangeproof
110-
*
111-
* .
112-
* / \
113-
* . S
114-
* / \
115-
* A I
116-
*/
104+
*/
117105
uint256 CTxInWitness::GetHash() const
118106
{
119107
std::vector<uint256> leaves;
120108
leaves.push_back(SerializeHash(vchIssuanceAmountRangeproof, SER_GETHASH, 0));
121109
leaves.push_back(SerializeHash(vchInflationKeysRangeproof, SER_GETHASH, 0));
122110
leaves.push_back(SerializeHash(scriptWitness.stack, SER_GETHASH, 0));
111+
leaves.push_back(SerializeHash(m_pegin_witness.stack, SER_GETHASH, 0));
123112
return ComputeFastMerkleRoot(leaves);
124113
}
125114

src/primitives/transaction.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,12 @@ class CTxIn
509509
class CTxInWitness
510510
{
511511
public:
512+
// TODO generalize CScriptWitness into just CWitness
512513
std::vector<unsigned char> vchIssuanceAmountRangeproof;
513514
std::vector<unsigned char> vchInflationKeysRangeproof;
514515
CScriptWitness scriptWitness;
516+
// Re-use script witness struct to include its own witness
517+
CScriptWitness m_pegin_witness;
515518

516519
ADD_SERIALIZE_METHODS;
517520

@@ -521,19 +524,21 @@ class CTxInWitness
521524
READWRITE(vchIssuanceAmountRangeproof);
522525
READWRITE(vchInflationKeysRangeproof);
523526
READWRITE(scriptWitness.stack);
527+
READWRITE(m_pegin_witness.stack);
524528
}
525529

526530
CTxInWitness() { }
527531

528532
bool IsNull() const
529533
{
530-
return vchIssuanceAmountRangeproof.empty() && vchInflationKeysRangeproof.empty() && scriptWitness.IsNull();
534+
return vchIssuanceAmountRangeproof.empty() && vchInflationKeysRangeproof.empty() && scriptWitness.IsNull() && m_pegin_witness.IsNull();
531535
}
532536
void SetNull()
533537
{
534538
vchIssuanceAmountRangeproof.clear();
535539
vchInflationKeysRangeproof.clear();
536540
scriptWitness.stack.clear();
541+
m_pegin_witness.stack.clear();
537542
}
538543

539544
uint256 GetHash() const;

0 commit comments

Comments
 (0)