rpc methods for cross chain transactions

This commit is contained in:
Scott Sadler
2018-05-22 15:16:37 -03:00
parent 0df96a2f06
commit 0b485d3c66
9 changed files with 74 additions and 32 deletions

View File

@@ -1,9 +1,14 @@
#include "cc/eval.h"
#include "importcoin.h"
#include "main.h"
#include "notarisationdb.h"
#include "komodo_structs.h"
/*
* This file is built in the server
*/
/* On KMD */
uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeight,
std::vector<uint256> &moms, uint256 &destNotarisationTxid)
@@ -123,6 +128,30 @@ cont:
}
/*
* Takes an importTx that has proof leading to assetchain root
* and extends proof to cross chain root
*/
void CompleteImportTransaction(CTransaction &importTx)
{
TxProof proof;
CTransaction burnTx;
std::vector<CTxOut> payouts;
if (!UnmarshalImportTx(importTx, proof, burnTx, payouts))
throw std::runtime_error("Couldn't parse importTx");
std::string targetSymbol;
uint32_t targetCCid;
uint256 payoutsHash;
if (!UnmarshalBurnTx(burnTx, targetSymbol, &targetCCid, payoutsHash))
throw std::runtime_error("Couldn't parse burnTx");
proof = GetCrossChainProof(burnTx.GetHash(), targetSymbol.data(), targetCCid, proof);
importTx = MakeImportCoinTransaction(proof, burnTx, importTx.vout);
}
struct notarized_checkpoint *komodo_npptr_at(int idx);
struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx);
@@ -236,3 +265,5 @@ TxProof GetAssetchainProof(uint256 hash)
CDataStream ssProof(SER_NETWORK, PROTOCOL_VERSION);
return std::make_pair(np->notarized_desttxid, MerkleBranch(nIndex, branch));
}