From da629dfe5af563aea3a0cb5345561635382c208c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 21 Aug 2018 04:40:10 -1100 Subject: [PATCH] MofN address --- src/cc/CCcustom.cpp | 19 +++++++++++++++++++ src/cc/CCutils.cpp | 2 +- src/cc/eval.h | 10 +++++++++- src/rpcserver.cpp | 3 +++ src/rpcserver.h | 1 + src/wallet/rpcwallet.cpp | 13 +++++++++++++ 6 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 9bf1d5449..33c41cbfd 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -128,6 +128,17 @@ uint8_t AuctionCCpriv[32] = { 0x8c, 0x1b, 0xb7, 0x8c, 0x02, 0xa3, 0x9d, 0x21, 0x #undef FUNCNAME #undef EVALCODE +// MofN +#define FUNCNAME IsMofNInput +#define EVALCODE EVAL_MOFN +const char *MofNCCaddr = "RL4YPX7JYG3FnvoPqWF2pn3nQknH5NWEwx"; +const char *MofNNormaladdr = "RTPwUjKYECcGn6Y4KYChLhgaht1RSU4jwf"; +char MofNCChexstr[67] = { "03c91bef3d7cc59c3a89286833a3446b29e52a5e773f738a1ad2b09785e5f4179e" }; +uint8_t MofNCCpriv[32] = { 0x8c, 0x1b, 0xb7, 0x8c, 0x02, 0xa3, 0x9d, 0x21, 0x28, 0x59, 0xf5, 0xea, 0xda, 0xec, 0x0d, 0x11, 0xcd, 0x38, 0x47, 0xac, 0x0b, 0x6f, 0x19, 0xc0, 0x24, 0x36, 0xbf, 0x1c, 0x0a, 0x06, 0x31, 0xfb }; +#include "CCcustom.inc" +#undef FUNCNAME +#undef EVALCODE + struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode) { cp->evalcode = evalcode; @@ -189,6 +200,14 @@ struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode) cp->validate = AuctionValidate; cp->ismyvin = IsAuctionInput; break; + case EVAL_MofN: + strcpy(cp->unspendableCCaddr,MofNCCaddr); + strcpy(cp->normaladdr,MofNNormaladdr); + strcpy(cp->CChexstr,MofNCChexstr); + memcpy(cp->CCpriv,MofNCCpriv,32); + cp->validate = MofNValidate; + cp->ismyvin = IsMofNInput; + break; } return(cp); } diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 4ca2f1c63..4c369621c 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -231,7 +231,7 @@ bool Myprivkey(uint8_t myprivkey[]) if ( pwalletMain->GetKey(keyID,vchSecret) != 0 ) { memcpy(myprivkey,vchSecret.begin(),32); - if ( 0 ) + if ( 1 ) { for (i=0; i<32; i++) fprintf(stderr,"0x%02x, ",myprivkey[i]); diff --git a/src/cc/eval.h b/src/cc/eval.h index 77c592a16..9ff0ca623 100644 --- a/src/cc/eval.h +++ b/src/cc/eval.h @@ -46,7 +46,15 @@ EVAL(EVAL_DICE, 0xe6) \ EVAL(EVAL_FSM, 0xe7) \ EVAL(EVAL_AUCTION, 0xe8) \ - EVAL(EVAL_LOTTO, 0xe9) + EVAL(EVAL_LOTTO, 0xe9) \ + EVAL(EVAL_MOFN, 0xea) \ + EVAL(EVAL_CHANNELS, 0xeb) \ + EVAL(EVAL_ORACLES, 0xec) \ + EVAL(EVAL_PRICES, 0xed) \ + EVAL(EVAL_PEGS, 0xee) \ + EVAL(EVAL_TRIGGERS, 0xef) \ + EVAL(EVAL_PAYMENTS, 0xf0) \ + EVAL(EVAL_GATEWAYS, 0xf1) typedef uint8_t EvalCode; diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 41228e71a..156783f85 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -371,6 +371,9 @@ static const CRPCCommand vRPCCommands[] = { "faucet", "faucetget", &faucetget, true }, { "faucet", "faucetaddress", &faucetaddress, true }, + /* MofN */ + { "MofN", "mofnaddress", &mofnaddress, true }, + /* dice */ { "dice", "dicelist", &dicelist, true }, { "dice", "diceinfo", &diceinfo, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index f88f1e571..be404982c 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -221,6 +221,7 @@ extern UniValue tokenfillbid(const UniValue& params, bool fHelp); extern UniValue tokenask(const UniValue& params, bool fHelp); extern UniValue tokencancelask(const UniValue& params, bool fHelp); extern UniValue tokenfillask(const UniValue& params, bool fHelp); +extern UniValue mofnaddress(const UniValue& params, bool fHelp); //extern UniValue tokenswapask(const UniValue& params, bool fHelp); //extern UniValue tokenfillswap(const UniValue& params, bool fHelp); extern UniValue faucetfund(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 05faaeeb1..3bcbc01a4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4873,6 +4873,19 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector pubkey; + cp = CCinit(&C,EVAL_MOFN); + if ( fHelp || params.size() > 1 ) + throw runtime_error("mofnaddress [pubkey]\n"); + if ( ensure_CCrequirements() < 0 ) + throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); + if ( params.size() == 1 ) + pubkey = ParseHex(params[0].get_str().c_str()); + return(CCaddress(cp,(char *)"Lotto",pubkey)); +} + UniValue lottoaddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey;