From 142f5c112f14724af67e4b4cf0fda557f2227e26 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 29 Dec 2018 01:47:55 -1100 Subject: [PATCH] Selfimport --- src/rpc/crosschain.cpp | 11 +++++------ src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/rpc/crosschain.cpp b/src/rpc/crosschain.cpp index 4495ab0f3..77ca43f73 100644 --- a/src/rpc/crosschain.cpp +++ b/src/rpc/crosschain.cpp @@ -263,7 +263,6 @@ UniValue migrate_completeimporttransaction(const UniValue& params, bool fHelp) return HexStr(E_MARSHAL(ss << importTx)); } -#ifdef selfimport UniValue selfimport(const UniValue& params, bool fHelp) { TxProof proof; CTransaction importTx,burnTx; CTxOut burnOut; uint64_t burnAmount; uint256 blockHash; @@ -272,10 +271,10 @@ UniValue selfimport(const UniValue& params, bool fHelp) if (fHelp || params.size() != 2) throw runtime_error("selfimport txid burnamount\n\n" "creates signed selfimport transaction from txid"); - //txid = - //burnAmount = - - if ( GetTransaction(txid,burnTx,hashBlock,false) == 0 ) + txid = Parseuint256((char *)params[0].get_str().c_str()); + burnAmount = atof(params[1].get_str().c_str()) * COIN + 0.00000000499999; + + if ( GetTransaction(txid,burnTx,blockHash,false) == 0 ) throw runtime_error("selfimport couldnt find txid"); if ( GetSelfimportProof(proof,burnTx,txid) < 0 ) throw std::runtime_error("Failed validating selfimport"); @@ -284,8 +283,8 @@ UniValue selfimport(const UniValue& params, bool fHelp) importTx = MakeImportCoinTransaction(proof,burnTx,payouts); importTx.vout.clear(); importTx.vout.push_back(burnOut); + return HexStr(E_MARSHAL(ss << importTx)); } -#endif UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp) { diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index a4ec30b25..5bdc0b3ce 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -334,6 +334,7 @@ static const CRPCCommand vRPCCommands[] = { "crosschain", "migrate_converttoexport", &migrate_converttoexport, true }, { "crosschain", "migrate_createimporttransaction", &migrate_createimporttransaction, true }, { "crosschain", "migrate_completeimporttransaction", &migrate_completeimporttransaction, true }, + { "crosschain", "selfimport", &selfimport, true }, /* Mining */ { "mining", "getblocktemplate", &getblocktemplate, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 7a8ed75e3..96e3da82f 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -392,6 +392,7 @@ extern UniValue getchaintips(const UniValue& params, bool fHelp); extern UniValue invalidateblock(const UniValue& params, bool fHelp); extern UniValue reconsiderblock(const UniValue& params, bool fHelp); extern UniValue getspentinfo(const UniValue& params, bool fHelp); +extern UniValue selfimport(const UniValue& params, bool fHelp); extern UniValue getblocksubsidy(const UniValue& params, bool fHelp);