change Eval data structure to single code blob
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* Crypto-Condition EVAL method that verifies a payout against a transaction
|
||||
* notarised on another chain.
|
||||
*
|
||||
* IN: cond - CC EVAL node
|
||||
* IN: params - condition params
|
||||
* IN: importTx - Payout transaction on value chain (KMD)
|
||||
* IN: nIn - index of input of stake
|
||||
*
|
||||
@@ -29,7 +29,7 @@
|
||||
* out 0: OP_RETURN hash of payouts
|
||||
* out 1-: anything
|
||||
*/
|
||||
bool Eval::ImportPayout(const CC *cond, const CTransaction &importTx, unsigned int nIn)
|
||||
bool Eval::ImportPayout(const std::vector<uint8_t> params, const CTransaction &importTx, unsigned int nIn)
|
||||
{
|
||||
if (importTx.vout.size() == 0) return Invalid("no-vouts");
|
||||
|
||||
@@ -37,10 +37,9 @@ bool Eval::ImportPayout(const CC *cond, const CTransaction &importTx, unsigned i
|
||||
MoMProof proof;
|
||||
CTransaction disputeTx;
|
||||
{
|
||||
std::pair<MoMProof&, CTransaction&> pair(proof, disputeTx);
|
||||
std::vector<unsigned char> vopret;
|
||||
GetOpReturnData(importTx.vout[0].scriptPubKey, vopret);
|
||||
if (!CheckDeserialize(vopret, pair))
|
||||
if (!E_UNMARSHAL(vopret, ss >> proof; ss >> disputeTx))
|
||||
return Invalid("invalid-payload");
|
||||
}
|
||||
|
||||
@@ -56,16 +55,18 @@ bool Eval::ImportPayout(const CC *cond, const CTransaction &importTx, unsigned i
|
||||
// Check disputeTx spends sessionTx.0
|
||||
// condition ImportPayout params is session ID from other chain
|
||||
{
|
||||
if (cond->paramsBinLength != 32) return Invalid("malformed-params");
|
||||
COutPoint prevout = disputeTx.vin[0].prevout;
|
||||
if (memcmp(prevout.hash.begin(), cond->paramsBin, 32) != 0 ||
|
||||
prevout.n != 0) return Invalid("wrong-session");
|
||||
uint256 sessionHash;
|
||||
if (!E_UNMARSHAL(params, ss >> sessionHash))
|
||||
return Invalid("malformed-params");
|
||||
if (disputeTx.vin[0].prevout != COutPoint(sessionHash, 0))
|
||||
return Invalid("wrong-session");
|
||||
}
|
||||
|
||||
// Check disputeTx solves momproof from vout[0]
|
||||
{
|
||||
NotarisationData data;
|
||||
if (!GetNotarisationData(proof.notarisationHash, data)) return Invalid("coudnt-load-mom");
|
||||
if (!GetNotarisationData(proof.notarisationHash, data))
|
||||
return Invalid("coudnt-load-mom");
|
||||
|
||||
if (data.MoM != proof.Exec(disputeTx.GetHash()))
|
||||
return Invalid("mom-check-fail");
|
||||
|
||||
Reference in New Issue
Block a user