mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
add pegin_witness to witness inputs
This commit is contained in:
parent
36b3ab1a22
commit
16973cd1d2
3 changed files with 15 additions and 20 deletions
|
|
@ -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) {}
|
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
|
* optional. The optional elements have to do with asset issuance
|
||||||
* and are not normally present, most of the time. For this reason
|
* and peg-in transactions, nor present most of the time.
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
* S : script witness
|
*/
|
||||||
* A : issuance amount rangeproof
|
|
||||||
* I : inflation keys rangeproof
|
|
||||||
*
|
|
||||||
* .
|
|
||||||
* / \
|
|
||||||
* . S
|
|
||||||
* / \
|
|
||||||
* A I
|
|
||||||
*/
|
|
||||||
uint256 CTxInWitness::GetHash() const
|
uint256 CTxInWitness::GetHash() const
|
||||||
{
|
{
|
||||||
std::vector<uint256> leaves;
|
std::vector<uint256> leaves;
|
||||||
leaves.push_back(SerializeHash(vchIssuanceAmountRangeproof, SER_GETHASH, 0));
|
leaves.push_back(SerializeHash(vchIssuanceAmountRangeproof, SER_GETHASH, 0));
|
||||||
leaves.push_back(SerializeHash(vchInflationKeysRangeproof, SER_GETHASH, 0));
|
leaves.push_back(SerializeHash(vchInflationKeysRangeproof, SER_GETHASH, 0));
|
||||||
leaves.push_back(SerializeHash(scriptWitness.stack, 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);
|
return ComputeFastMerkleRoot(leaves);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -509,9 +509,12 @@ public:
|
||||||
class CTxInWitness
|
class CTxInWitness
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// TODO generalize CScriptWitness into just CWitness
|
||||||
std::vector<unsigned char> vchIssuanceAmountRangeproof;
|
std::vector<unsigned char> vchIssuanceAmountRangeproof;
|
||||||
std::vector<unsigned char> vchInflationKeysRangeproof;
|
std::vector<unsigned char> vchInflationKeysRangeproof;
|
||||||
CScriptWitness scriptWitness;
|
CScriptWitness scriptWitness;
|
||||||
|
// Re-use script witness struct to include its own witness
|
||||||
|
CScriptWitness m_pegin_witness;
|
||||||
|
|
||||||
ADD_SERIALIZE_METHODS;
|
ADD_SERIALIZE_METHODS;
|
||||||
|
|
||||||
|
|
@ -521,19 +524,21 @@ public:
|
||||||
READWRITE(vchIssuanceAmountRangeproof);
|
READWRITE(vchIssuanceAmountRangeproof);
|
||||||
READWRITE(vchInflationKeysRangeproof);
|
READWRITE(vchInflationKeysRangeproof);
|
||||||
READWRITE(scriptWitness.stack);
|
READWRITE(scriptWitness.stack);
|
||||||
|
READWRITE(m_pegin_witness.stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTxInWitness() { }
|
CTxInWitness() { }
|
||||||
|
|
||||||
bool IsNull() const
|
bool IsNull() const
|
||||||
{
|
{
|
||||||
return vchIssuanceAmountRangeproof.empty() && vchInflationKeysRangeproof.empty() && scriptWitness.IsNull();
|
return vchIssuanceAmountRangeproof.empty() && vchInflationKeysRangeproof.empty() && scriptWitness.IsNull() && m_pegin_witness.IsNull();
|
||||||
}
|
}
|
||||||
void SetNull()
|
void SetNull()
|
||||||
{
|
{
|
||||||
vchIssuanceAmountRangeproof.clear();
|
vchIssuanceAmountRangeproof.clear();
|
||||||
vchInflationKeysRangeproof.clear();
|
vchInflationKeysRangeproof.clear();
|
||||||
scriptWitness.stack.clear();
|
scriptWitness.stack.clear();
|
||||||
|
m_pegin_witness.stack.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 GetHash() const;
|
uint256 GetHash() const;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue