cross chain rpc methods

This commit is contained in:
Scott Sadler
2018-05-18 19:29:33 -03:00
parent 06c960d2b7
commit e4f943d86d
18 changed files with 264 additions and 305 deletions

View File

@@ -154,7 +154,7 @@ uint32_t Eval::GetCurrentLedgerID() const
/*
* Get MoM from a notarisation tx hash
* Get MoM from a notarisation tx hash (on KMD)
*/
bool Eval::GetNotarisationData(const uint256 notaryHash, NotarisationData &data) const
{
@@ -166,9 +166,11 @@ bool Eval::GetNotarisationData(const uint256 notaryHash, NotarisationData &data)
return true;
}
bool Eval::GetNotarisationData(int notarisationHeight, NotarisationData &data, bool verifyCanonical) const
/*
* Get MoMoM corresponding to a notarisation tx hash (on assetchain)
*/
bool Eval::GetProofRoot(uint256 kmdNotarisationHash, uint256 &momom) const
{
return false;
}

View File

@@ -72,8 +72,7 @@ public:
virtual bool GetBlock(uint256 hash, CBlockIndex& blockIdx) const;
virtual int32_t GetNotaries(uint8_t pubkeys[64][33], int32_t height, uint32_t timestamp) const;
virtual bool GetNotarisationData(uint256 notarisationHash, NotarisationData &data) const;
virtual bool GetNotarisationData(int notarisationHeight, NotarisationData &data,
bool verifyCanonical) const;
virtual bool GetProofRoot(uint256 kmdNotarisationHash, uint256 &momom) const;
virtual bool CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t timestamp) const;
virtual uint32_t GetCurrentLedgerID() const;
};
@@ -228,6 +227,9 @@ public:
};
typedef std::pair<uint256,MerkleBranch> TxProof;
uint256 GetMerkleRoot(const std::vector<uint256>& vLeaves);

View File

@@ -15,7 +15,7 @@ bool Eval::ImportCoin(const std::vector<uint8_t> params, const CTransaction &imp
if (importTx.vout.size() == 0) return Invalid("no-vouts");
// params
MomoProof proof;
TxProof proof;
CTransaction burnTx;
if (!E_UNMARSHAL(params, ss >> proof; ss >> burnTx))
return Invalid("invalid-params");
@@ -56,11 +56,11 @@ bool Eval::ImportCoin(const std::vector<uint8_t> params, const CTransaction &imp
// Check proof confirms existance of burnTx
{
NotarisationData data(1);
if (!GetNotarisationData(proof.notarisationHeight, data, true))
uint256 momom;
if (!GetProofRoot(proof.first, momom))
return Invalid("coudnt-load-momom");
if (data.MoMoM != proof.branch.Exec(burnTx.GetHash()))
if (momom != proof.second.Exec(burnTx.GetHash()))
return Invalid("momom-check-fail");
}