Delete many things we do not want or need
This commit is contained in:
@@ -223,32 +223,6 @@ cont:
|
||||
return std::make_pair(targetChainNotarizationTxid,newBranch);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Takes an importTx that has proof leading to assetchain root
|
||||
* and extends proof to cross chain root
|
||||
*/
|
||||
void CompleteImportTransaction(CTransaction &importTx, int32_t offset)
|
||||
{
|
||||
ImportProof proof; CTransaction burnTx; std::vector<CTxOut> payouts; std::vector<uint8_t> rawproof;
|
||||
if (!UnmarshalImportTx(importTx, proof, burnTx, payouts))
|
||||
throw std::runtime_error("Couldn't unmarshal importTx");
|
||||
|
||||
std::string targetSymbol;
|
||||
uint32_t targetCCid;
|
||||
uint256 payoutsHash;
|
||||
if (!UnmarshalBurnTx(burnTx, targetSymbol, &targetCCid, payoutsHash, rawproof))
|
||||
throw std::runtime_error("Couldn't unmarshal burnTx");
|
||||
|
||||
TxProof merkleBranch;
|
||||
if( !proof.IsMerkleBranch(merkleBranch) )
|
||||
throw std::runtime_error("Incorrect import tx proof");
|
||||
TxProof newMerkleBranch = GetCrossChainProof(burnTx.GetHash(), targetSymbol.data(), targetCCid, merkleBranch, offset);
|
||||
ImportProof newProof(newMerkleBranch);
|
||||
|
||||
importTx = MakeImportCoinTransaction(newProof, burnTx, payouts);
|
||||
}
|
||||
|
||||
bool IsSameAssetChain(const Notarization ¬a) {
|
||||
return strcmp(nota.second.symbol, SMART_CHAIN_SYMBOL) == 0;
|
||||
};
|
||||
@@ -308,112 +282,6 @@ bool CheckMoMoM(uint256 hushNotarizationHash, uint256 momom)
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Check notaries approvals for the txoutproofs of burn tx
|
||||
* (alternate check if MoMoM check has failed)
|
||||
* Params:
|
||||
* burntxid - txid of burn tx on the source chain
|
||||
* rawproof - array of txids of notaries' proofs
|
||||
*/
|
||||
bool CheckNotariesApproval(uint256 burntxid, const std::vector<uint256> & notaryTxids)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
// get notaries:
|
||||
uint8_t notaries_pubkeys[64][33];
|
||||
std::vector< std::vector<uint8_t> > alreadySigned;
|
||||
|
||||
//unmarshal notaries approval txids
|
||||
for(auto notarytxid : notaryTxids ) {
|
||||
EvalRef eval;
|
||||
CBlockIndex block;
|
||||
CTransaction notarytx; // tx with notary approval of txproof existence
|
||||
|
||||
// get notary approval tx
|
||||
if (eval->GetTxConfirmed(notarytxid, notarytx, block)) {
|
||||
|
||||
std::vector<uint8_t> vopret;
|
||||
if (!notarytx.vout.empty() && GetOpReturnData(notarytx.vout.back().scriptPubKey, vopret)) {
|
||||
std::vector<uint8_t> txoutproof;
|
||||
|
||||
if (E_UNMARSHAL(vopret, ss >> txoutproof)) {
|
||||
CMerkleBlock merkleBlock;
|
||||
std::vector<uint256> prooftxids;
|
||||
// extract block's merkle tree
|
||||
if (E_UNMARSHAL(txoutproof, ss >> merkleBlock)) {
|
||||
|
||||
// extract proven txids:
|
||||
merkleBlock.txn.ExtractMatches(prooftxids);
|
||||
if (merkleBlock.txn.ExtractMatches(prooftxids) != merkleBlock.header.hashMerkleRoot || // check block merkle root is correct
|
||||
std::find(prooftxids.begin(), prooftxids.end(), burntxid) != prooftxids.end()) { // check burn txid is in proven txids list
|
||||
|
||||
if (hush_notaries(notaries_pubkeys, block.GetHeight(), block.GetBlockTime()) >= 0) {
|
||||
// check it is a notary who signed approved tx:
|
||||
int i;
|
||||
for (i = 0; i < sizeof(notaries_pubkeys) / sizeof(notaries_pubkeys[0]); i++) {
|
||||
std::vector<uint8_t> vnotarypubkey(notaries_pubkeys[i], notaries_pubkeys[i] + 33);
|
||||
#ifdef TESTMODE
|
||||
char test_notary_pubkey_hex[] = "029fa302968bbae81f41983d2ec20445557b889d31227caec5d910d19b7510ef86";
|
||||
uint8_t test_notary_pubkey33[33];
|
||||
decode_hex(test_notary_pubkey33, 33, test_notary_pubkey_hex);
|
||||
#endif
|
||||
if (CheckVinPubKey(notarytx, 0, notaries_pubkeys[i]) // is signed by a notary?
|
||||
&& std::find(alreadySigned.begin(), alreadySigned.end(), vnotarypubkey) == alreadySigned.end() // check if notary not re-used
|
||||
#ifdef TESTMODE
|
||||
|| CheckVinPubKey(notarytx, 0, test_notary_pubkey33) // test
|
||||
#endif
|
||||
)
|
||||
{
|
||||
alreadySigned.push_back(vnotarypubkey);
|
||||
count++;
|
||||
LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "CheckNotariesApproval() notary approval checked, count=" << count << std::endl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == sizeof(notaries_pubkeys) / sizeof(notaries_pubkeys[0]))
|
||||
LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "CheckNotariesApproval() txproof not signed by a notary or reused" << std::endl);
|
||||
}
|
||||
else {
|
||||
LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckNotariesApproval() cannot get current notaries pubkeys" << std::endl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckNotariesApproval() burntxid not found in txoutproof or incorrect txoutproof" << std::endl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckNotariesApproval() could not unmarshal merkleBlock" << std::endl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckNotariesApproval() could not unmarshal txoutproof" << std::endl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckNotariesApproval() no opret in the notary tx" << std::endl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckNotariesApproval() could not load notary tx" << std::endl);
|
||||
}
|
||||
}
|
||||
|
||||
bool retcode;
|
||||
#ifdef TESTMODE
|
||||
if (count < 1) { // 1 for test
|
||||
#else
|
||||
if (count < 5) {
|
||||
#endif
|
||||
LOGSTREAM("importcoin", CCLOG_INFO, stream << "CheckNotariesApproval() not enough signed notary transactions=" << count << std::endl);
|
||||
retcode = false;
|
||||
}
|
||||
else
|
||||
retcode = true;
|
||||
|
||||
return retcode;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* On assetchain
|
||||
* in: txid
|
||||
|
||||
Reference in New Issue
Block a user