Browse Source

recognize btc backnotarisations and include ccid in MoMoMdata rpc

pull/4/head
Scott Sadler 6 years ago
parent
commit
a748b1a26d
  1. 30
      src/cc/eval.h
  2. 25
      src/rpccrosschain.cpp

30
src/cc/eval.h

@ -124,13 +124,6 @@ extern char ASSETCHAINS_SYMBOL[65];
*/
class NotarisationData
{
bool IsBack()
{
if (IsBackNotarisation == 2) {
return ASSETCHAINS_SYMBOL[0] != 0;
}
return (bool) IsBackNotarisation;
}
public:
int IsBackNotarisation = 0;
uint256 blockHash;
@ -149,16 +142,21 @@ public:
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool IsBack = IsBackNotarisation;
if (2 == IsBackNotarisation) IsBack = AutoIsBackNotarisation(s, ser_action);
READWRITE(blockHash);
READWRITE(height);
if (IsBack())
if (IsBack)
READWRITE(txHash);
SerSymbol(s, ser_action);
if (s.size() == 0) return;
READWRITE(MoM);
READWRITE(MoMDepth);
if (s.size() == 0) return;
READWRITE(ccId);
if (IsBack()) {
if (IsBack) {
READWRITE(MoMoM);
READWRITE(MoMoMDepth);
}
@ -178,6 +176,20 @@ public:
throw std::ios_base::failure("couldn't parse symbol");
s.read(symbol, nullPos-&s[0]+1);
}
template <typename Stream>
bool AutoIsBackNotarisation(Stream& s, CSerActionUnserialize act)
{
if (ASSETCHAINS_SYMBOL[0]) return 1;
if (s.size() >= 72 && strcmp("BTC", &s[68]) == 0) return 1;
return 0;
}
template <typename Stream>
bool AutoIsBackNotarisation(Stream& s, CSerActionSerialize act)
{
return !txHash.IsNull();
}
};

25
src/rpccrosschain.cpp

@ -50,29 +50,10 @@ UniValue assetchainproof(const UniValue& params, bool fHelp)
UniValue crosschainproof(const UniValue& params, bool fHelp)
{
}
UniValue getproofroot(const UniValue& params, bool fHelp)
{
std::string symbol;
int kmdHeight;
// parse params and get notarisation data for tx
if ( fHelp || params.size() != 2)
throw runtime_error("getproofroot needs a symbol and a kmdHeight");
symbol = params[0].get_str();
kmdHeight = atoi(params[0].get_str().c_str());
if (kmdHeight <= 0)
throw runtime_error("Invalid kmdHeight");
UniValue ret(UniValue::VOBJ);
return ret;
}
UniValue height_MoM(const UniValue& params, bool fHelp)
{
int32_t height,depth,notarized_height,MoMoMdepth,MoMoMoffset,kmdstarti,kmdendi; uint256 MoM,MoMoM,kmdtxid; uint32_t timestamp = 0; UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR);
@ -120,10 +101,10 @@ UniValue MoMoMdata(const UniValue& params, bool fHelp)
UniValue ret(UniValue::VOBJ);
char* symbol = (char *)params[0].get_str().c_str();
int kmdheight = atoi(params[1].get_str().c_str());
int ccid = atoi(params[2].get_str().c_str());
uint32_t ccid = atoi(params[2].get_str().c_str());
ret.push_back(Pair("coin",symbol));
ret.push_back(Pair("kmdheight",kmdheight));
ret.push_back(Pair("ccid", ccid));
ret.push_back(Pair("ccid", (int) ccid));
uint256 destNotarisationTxid;
std::vector<uint256> moms;
@ -134,7 +115,7 @@ UniValue MoMoMdata(const UniValue& params, bool fHelp)
ret.push_back(Pair("MoMs", valMoms));
ret.push_back(Pair("notarization_hash", destNotarisationTxid.GetHex()));
ret.push_back(Pair("MoMoM", MoMoM.GetHex()));
auto vmomomdata = E_MARSHAL(ss << MoMoM; ss << ((uint32_t)0));
auto vmomomdata = E_MARSHAL(ss << ccid; ss << MoMoM; ss << ((uint32_t)0));
ret.push_back(Pair("data", HexStr(vmomomdata)));
return ret;
}

Loading…
Cancel
Save