|
|
|
#include "cc/eval.h"
|
|
|
|
#include "crosschain.h"
|
|
|
|
#include "notarisationdb.h"
|
|
|
|
#include "notaries_STAKED.h"
|
|
|
|
|
|
|
|
//extern char *notaries_STAKED;
|
|
|
|
|
|
|
|
int GetSymbolAuthority(const char* symbol)
|
|
|
|
{
|
|
|
|
if (strncmp(symbol, "TXSCL", 5) == 0)
|
|
|
|
return CROSSCHAIN_TXSCL;
|
|
|
|
if ( (strncmp(symbol, "STKD", 4) == 0) || (strncmp(symbol, "STAKED", 6) == 0) )
|
|
|
|
return CROSSCHAIN_STAKED;
|
|
|
|
return CROSSCHAIN_KOMODO;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CheckTxAuthority(const CTransaction &tx, CrosschainAuthority auth)
|
|
|
|
{
|
|
|
|
EvalRef eval;
|
|
|
|
|
|
|
|
if (tx.vin.size() < auth.requiredSigs) return false;
|
|
|
|
|
|
|
|
uint8_t seen[64] = {0};
|
|
|
|
|
|
|
|
BOOST_FOREACH(const CTxIn &txIn, tx.vin)
|
|
|
|
{
|
|
|
|
// Get notary pubkey
|
|
|
|
CTransaction tx;
|
|
|
|
uint256 hashBlock;
|
|
|
|
if (!eval->GetTxUnconfirmed(txIn.prevout.hash, tx, hashBlock)) return false;
|
|
|
|
if (tx.vout.size() < txIn.prevout.n) return false;
|
|
|
|
CScript spk = tx.vout[txIn.prevout.n].scriptPubKey;
|
|
|
|
if (spk.size() != 35) return false;
|
|
|
|
const unsigned char *pk = spk.data();
|
|
|
|
if (pk++[0] != 33) return false;
|
|
|
|
if (pk[33] != OP_CHECKSIG) return false;
|
|
|
|
|
|
|
|
// Check it's a notary
|
|
|
|
for (int i=0; i<auth.size; i++) {
|
|
|
|
if (!seen[i]) {
|
|
|
|
if (memcmp(pk, auth.notaries[i], 33) == 0) {
|
|
|
|
seen[i] = 1;
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
found:;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const CrosschainAuthority auth_STAKED = [&](){
|
|
|
|
CrosschainAuthority auth;
|
|
|
|
auth.size = (int32_t)(sizeof(notaries_STAKED)/sizeof(*notaries_STAKED));
|
|
|
|
auth.requiredSigs = 3;
|
|
|
|
for (int n=0; n<auth.size; n++)
|
|
|
|
for (size_t i=0; i<33; i++)
|
|
|
|
sscanf(notaries_STAKED[n][1]+(i*2), "%2hhx", auth.notaries[n]+i);
|
|
|
|
return auth;
|
|
|
|
}();
|