FSM skeleton
This commit is contained in:
@@ -266,7 +266,7 @@ libbitcoin_server_a_SOURCES = \
|
|||||||
cc/rewards.cpp \
|
cc/rewards.cpp \
|
||||||
cc/dice.cpp \
|
cc/dice.cpp \
|
||||||
cc/lotto.cpp \
|
cc/lotto.cpp \
|
||||||
cc/ponzi.cpp \
|
cc/fsm.cpp \
|
||||||
cc/auction.cpp \
|
cc/auction.cpp \
|
||||||
cc/betprotocol.cpp \
|
cc/betprotocol.cpp \
|
||||||
chain.cpp \
|
chain.cpp \
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "CCdice.h"
|
#include "CCdice.h"
|
||||||
#include "CCauction.h"
|
#include "CCauction.h"
|
||||||
#include "CClotto.h"
|
#include "CClotto.h"
|
||||||
#include "CCponzi.h"
|
#include "CCfsm.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CCcustom has most of the functions that need to be extended to create a new CC contract.
|
CCcustom has most of the functions that need to be extended to create a new CC contract.
|
||||||
@@ -106,13 +106,13 @@ uint8_t LottoCCpriv[32] = { 0xb4, 0xac, 0xc2, 0xd9, 0x67, 0x34, 0xd7, 0x58, 0x80
|
|||||||
#undef FUNCNAME
|
#undef FUNCNAME
|
||||||
#undef EVALCODE
|
#undef EVALCODE
|
||||||
|
|
||||||
// Ponzi
|
// Finite State Machine
|
||||||
#define FUNCNAME IsPonziInput
|
#define FUNCNAME IsFSMInput
|
||||||
#define EVALCODE EVAL_PONZI
|
#define EVALCODE EVAL_FSM
|
||||||
const char *PonziCCaddr = "RUKTbLBeKgHkm3Ss4hKZP3ikuLW1xx7B2x";
|
const char *FSMCCaddr = "RUKTbLBeKgHkm3Ss4hKZP3ikuLW1xx7B2x";
|
||||||
const char *PonziNormaladdr = "RWSHRbxnJYLvDjpcQ2i8MekgP6h2ctTKaj";
|
const char *FSMNormaladdr = "RWSHRbxnJYLvDjpcQ2i8MekgP6h2ctTKaj";
|
||||||
char PonziCChexstr[67] = { "039b52d294b413b07f3643c1a28c5467901a76562d8b39a785910ae0a0f3043810" };
|
char FSMCChexstr[67] = { "039b52d294b413b07f3643c1a28c5467901a76562d8b39a785910ae0a0f3043810" };
|
||||||
uint8_t PonziCCpriv[32] = { 0x11, 0xe1, 0xea, 0x3e, 0xdb, 0x36, 0xf0, 0xa8, 0xc6, 0x34, 0xe1, 0x21, 0xb8, 0x02, 0xb9, 0x4b, 0x12, 0x37, 0x8f, 0xa0, 0x86, 0x23, 0x50, 0xb2, 0x5f, 0xe4, 0xe7, 0x36, 0x0f, 0xda, 0xae, 0xfc };
|
uint8_t FSMCCpriv[32] = { 0x11, 0xe1, 0xea, 0x3e, 0xdb, 0x36, 0xf0, 0xa8, 0xc6, 0x34, 0xe1, 0x21, 0xb8, 0x02, 0xb9, 0x4b, 0x12, 0x37, 0x8f, 0xa0, 0x86, 0x23, 0x50, 0xb2, 0x5f, 0xe4, 0xe7, 0x36, 0x0f, 0xda, 0xae, 0xfc };
|
||||||
#include "CCcustom.inc"
|
#include "CCcustom.inc"
|
||||||
#undef FUNCNAME
|
#undef FUNCNAME
|
||||||
#undef EVALCODE
|
#undef EVALCODE
|
||||||
@@ -173,13 +173,13 @@ struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode)
|
|||||||
cp->validate = LottoValidate;
|
cp->validate = LottoValidate;
|
||||||
cp->ismyvin = IsLottoInput;
|
cp->ismyvin = IsLottoInput;
|
||||||
break;
|
break;
|
||||||
case EVAL_PONZI:
|
case EVAL_FSM:
|
||||||
strcpy(cp->unspendableCCaddr,PonziCCaddr);
|
strcpy(cp->unspendableCCaddr,FSMCCaddr);
|
||||||
strcpy(cp->normaladdr,PonziNormaladdr);
|
strcpy(cp->normaladdr,FSMNormaladdr);
|
||||||
strcpy(cp->CChexstr,PonziCChexstr);
|
strcpy(cp->CChexstr,FSMCChexstr);
|
||||||
memcpy(cp->CCpriv,PonziCCpriv,32);
|
memcpy(cp->CCpriv,FSMCCpriv,32);
|
||||||
cp->validate = PonziValidate;
|
cp->validate = FSMValidate;
|
||||||
cp->ismyvin = IsPonziInput;
|
cp->ismyvin = IsFSMInput;
|
||||||
break;
|
break;
|
||||||
case EVAL_AUCTION:
|
case EVAL_AUCTION:
|
||||||
strcpy(cp->unspendableCCaddr,AuctionCCaddr);
|
strcpy(cp->unspendableCCaddr,AuctionCCaddr);
|
||||||
|
|||||||
@@ -14,16 +14,17 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef CC_PONZI_H
|
#ifndef CC_FSM_H
|
||||||
#define CC_PONZI_H
|
#define CC_FSM_H
|
||||||
|
|
||||||
#include "CCinclude.h"
|
#include "CCinclude.h"
|
||||||
|
|
||||||
#define EVAL_PONZI 0xe7
|
#define EVAL_FSM 0xe7
|
||||||
|
|
||||||
bool PonziValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx);
|
bool FSMValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx);
|
||||||
|
|
||||||
std::string PonziBuy(uint64_t txfee,uint64_t amount);
|
std::string FSMlist(uint64_t txfee);
|
||||||
std::string PonziClaim(uint64_t txfee);
|
std::string FSMinfo(uint64_t txfee,uint256 fsmtxid);
|
||||||
|
std::string FSMcreate(uint64_t txfee,std::string name,std::string states);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "CCdice.h"
|
#include "CCdice.h"
|
||||||
|
|
||||||
// timeout, validate
|
// timeout, validate, verify win/loss can be used for entropy
|
||||||
|
|
||||||
/*
|
/*
|
||||||
in order to implement a dice game, we need a source of entropy, reasonably fast completion time and a way to manage the utxos.
|
in order to implement a dice game, we need a source of entropy, reasonably fast completion time and a way to manage the utxos.
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
EVAL(EVAL_FAUCET, 0xe4) \
|
EVAL(EVAL_FAUCET, 0xe4) \
|
||||||
EVAL(EVAL_REWARDS, 0xe5) \
|
EVAL(EVAL_REWARDS, 0xe5) \
|
||||||
EVAL(EVAL_DICE, 0xe6) \
|
EVAL(EVAL_DICE, 0xe6) \
|
||||||
EVAL(EVAL_PONZI, 0xe7) \
|
EVAL(EVAL_FSM, 0xe7) \
|
||||||
EVAL(EVAL_AUCTION, 0xe8) \
|
EVAL(EVAL_AUCTION, 0xe8) \
|
||||||
EVAL(EVAL_LOTTO, 0xe9)
|
EVAL(EVAL_LOTTO, 0xe9)
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "CCponzi.h"
|
#include "CCfsm.h"
|
||||||
#include "../txmempool.h"
|
#include "../txmempool.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
// start of consensus code
|
// start of consensus code
|
||||||
|
|
||||||
uint64_t IsPonzivout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v)
|
uint64_t IsFSMvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v)
|
||||||
{
|
{
|
||||||
char destaddr[64];
|
char destaddr[64];
|
||||||
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
||||||
@@ -32,7 +32,7 @@ uint64_t IsPonzivout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PonziExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee)
|
bool FSMExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee)
|
||||||
{
|
{
|
||||||
static uint256 zerohash;
|
static uint256 zerohash;
|
||||||
CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; uint64_t inputs=0,outputs=0,assetoshis;
|
CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; uint64_t inputs=0,outputs=0,assetoshis;
|
||||||
@@ -50,8 +50,8 @@ bool PonziExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction
|
|||||||
{
|
{
|
||||||
//fprintf(stderr,"vini.%d check hash and vout\n",i);
|
//fprintf(stderr,"vini.%d check hash and vout\n",i);
|
||||||
if ( hashBlock == zerohash )
|
if ( hashBlock == zerohash )
|
||||||
return eval->Invalid("cant ponzi from mempool");
|
return eval->Invalid("cant FSM from mempool");
|
||||||
if ( (assetoshis= IsPonzivout(cp,vinTx,tx.vin[i].prevout.n)) != 0 )
|
if ( (assetoshis= IsFSMvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 )
|
||||||
inputs += assetoshis;
|
inputs += assetoshis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ bool PonziExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction
|
|||||||
for (i=0; i<numvouts; i++)
|
for (i=0; i<numvouts; i++)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts);
|
//fprintf(stderr,"i.%d of numvouts.%d\n",i,numvouts);
|
||||||
if ( (assetoshis= IsPonzivout(cp,tx,i)) != 0 )
|
if ( (assetoshis= IsFSMvout(cp,tx,i)) != 0 )
|
||||||
outputs += assetoshis;
|
outputs += assetoshis;
|
||||||
}
|
}
|
||||||
if ( inputs != outputs+COIN+txfee )
|
if ( inputs != outputs+COIN+txfee )
|
||||||
@@ -70,7 +70,7 @@ bool PonziExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction
|
|||||||
else return(true);
|
else return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PonziValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx)
|
bool FSMValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx)
|
||||||
{
|
{
|
||||||
int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval;
|
int32_t numvins,numvouts,preventCCvins,preventCCvouts,i; bool retval;
|
||||||
numvins = tx.vin.size();
|
numvins = tx.vin.size();
|
||||||
@@ -85,30 +85,30 @@ bool PonziValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx)
|
|||||||
{
|
{
|
||||||
if ( IsCCInput(tx.vin[0].scriptSig) == 0 )
|
if ( IsCCInput(tx.vin[0].scriptSig) == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"ponziget invalid vini\n");
|
fprintf(stderr,"fsmget invalid vini\n");
|
||||||
return eval->Invalid("illegal normal vini");
|
return eval->Invalid("illegal normal vini");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"check amounts\n");
|
//fprintf(stderr,"check amounts\n");
|
||||||
if ( PonziExactAmounts(cp,eval,tx,1,10000) == false )
|
if ( FSMExactAmounts(cp,eval,tx,1,10000) == false )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"ponziget invalid amount\n");
|
fprintf(stderr,"fsmget invalid amount\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
preventCCvouts = 1;
|
preventCCvouts = 1;
|
||||||
if ( IsPonzivout(cp,tx,0) != 0 )
|
if ( IsFSMvout(cp,tx,0) != 0 )
|
||||||
{
|
{
|
||||||
preventCCvouts++;
|
preventCCvouts++;
|
||||||
i = 1;
|
i = 1;
|
||||||
} else i = 0;
|
} else i = 0;
|
||||||
if ( tx.vout[i].nValue != COIN )
|
if ( tx.vout[i].nValue != COIN )
|
||||||
return eval->Invalid("invalid ponzi output");
|
return eval->Invalid("invalid fsm output");
|
||||||
retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts);
|
retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts);
|
||||||
if ( retval != 0 )
|
if ( retval != 0 )
|
||||||
fprintf(stderr,"ponziget validated\n");
|
fprintf(stderr,"fsmget validated\n");
|
||||||
else fprintf(stderr,"ponziget invalid\n");
|
else fprintf(stderr,"fsmget invalid\n");
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ bool PonziValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx)
|
|||||||
|
|
||||||
// helper functions for rpc calls in rpcwallet.cpp
|
// helper functions for rpc calls in rpcwallet.cpp
|
||||||
|
|
||||||
uint64_t AddPonziInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint64_t total,int32_t maxinputs)
|
uint64_t AddFSMInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint64_t total,int32_t maxinputs)
|
||||||
{
|
{
|
||||||
char coinaddr[64]; uint64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector<uint8_t> origpubkey; CTransaction vintx; int32_t n = 0;
|
char coinaddr[64]; uint64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector<uint8_t> origpubkey; CTransaction vintx; int32_t n = 0;
|
||||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||||
@@ -131,7 +131,7 @@ uint64_t AddPonziInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub
|
|||||||
continue;
|
continue;
|
||||||
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 )
|
if ( GetTransaction(txid,vintx,hashBlock,false) != 0 )
|
||||||
{
|
{
|
||||||
if ( (nValue= IsPonzivout(cp,vintx,(int32_t)it->first.index)) > 0 )
|
if ( (nValue= IsFSMvout(cp,vintx,(int32_t)it->first.index)) > 0 )
|
||||||
{
|
{
|
||||||
if ( total != 0 && maxinputs != 0 )
|
if ( total != 0 && maxinputs != 0 )
|
||||||
mtx.vin.push_back(CTxIn(txid,(int32_t)it->first.index,CScript()));
|
mtx.vin.push_back(CTxIn(txid,(int32_t)it->first.index,CScript()));
|
||||||
@@ -146,37 +146,42 @@ uint64_t AddPonziInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub
|
|||||||
return(totalinputs);
|
return(totalinputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PonziBuy(uint64_t txfee,uint64_t amount)
|
std::string FSMlist(uint64_t txfee)
|
||||||
{
|
{
|
||||||
CMutableTransaction mtx; CPubKey mypk,ponzipk; CScript opret; uint64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C;
|
return(0);
|
||||||
cp = CCinit(&C,EVAL_PONZI);
|
}
|
||||||
|
|
||||||
|
std::string FSMcreate(uint64_t txfee,std::string name,std::string states)
|
||||||
|
{
|
||||||
|
CMutableTransaction mtx; CPubKey mypk,fsmpk; CScript opret; uint64_t inputs,CCchange=0,nValue=COIN; struct CCcontract_info *cp,C;
|
||||||
|
cp = CCinit(&C,EVAL_FSM);
|
||||||
if ( txfee == 0 )
|
if ( txfee == 0 )
|
||||||
txfee = 10000;
|
txfee = 10000;
|
||||||
ponzipk = GetUnspendable(cp,0);
|
fsmpk = GetUnspendable(cp,0);
|
||||||
mypk = pubkey2pk(Mypubkey());
|
mypk = pubkey2pk(Mypubkey());
|
||||||
if ( (inputs= AddPonziInputs(cp,mtx,ponzipk,nValue+txfee,60)) > 0 )
|
if ( (inputs= AddFSMInputs(cp,mtx,fsmpk,nValue+txfee,60)) > 0 )
|
||||||
{
|
{
|
||||||
if ( inputs > nValue )
|
if ( inputs > nValue )
|
||||||
CCchange = (inputs - nValue - txfee);
|
CCchange = (inputs - nValue - txfee);
|
||||||
if ( CCchange != 0 )
|
if ( CCchange != 0 )
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_PONZI,CCchange,ponzipk));
|
mtx.vout.push_back(MakeCC1vout(EVAL_FSM,CCchange,fsmpk));
|
||||||
mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
|
mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
|
||||||
return(FinalizeCCTx(-1LL,cp,mtx,mypk,txfee,opret));
|
return(FinalizeCCTx(-1LL,cp,mtx,mypk,txfee,opret));
|
||||||
} else fprintf(stderr,"cant find ponzi inputs\n");
|
} else fprintf(stderr,"cant find fsm inputs\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PonziClaim(uint64_t txfee)
|
std::string FSMinfo(uint64_t txfee,uint256 fsmtxid)
|
||||||
{
|
{
|
||||||
CMutableTransaction mtx; CPubKey mypk,ponzipk; uint64_t funds = 0; CScript opret; struct CCcontract_info *cp,C;
|
CMutableTransaction mtx; CPubKey mypk,fsmpk; uint64_t funds = 0; CScript opret; struct CCcontract_info *cp,C;
|
||||||
cp = CCinit(&C,EVAL_PONZI);
|
cp = CCinit(&C,EVAL_FSM);
|
||||||
if ( txfee == 0 )
|
if ( txfee == 0 )
|
||||||
txfee = 10000;
|
txfee = 10000;
|
||||||
mypk = pubkey2pk(Mypubkey());
|
mypk = pubkey2pk(Mypubkey());
|
||||||
ponzipk = GetUnspendable(cp,0);
|
fsmpk = GetUnspendable(cp,0);
|
||||||
if ( AddNormalinputs(mtx,mypk,txfee,64) > 0 )
|
if ( AddNormalinputs(mtx,mypk,txfee,64) > 0 )
|
||||||
{
|
{
|
||||||
mtx.vout.push_back(MakeCC1vout(EVAL_PONZI,funds,ponzipk));
|
mtx.vout.push_back(MakeCC1vout(EVAL_FSM,funds,fsmpk));
|
||||||
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret));
|
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret));
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
@@ -350,8 +350,11 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
/* lotto */
|
/* lotto */
|
||||||
{ "lotto", "lottoaddress", &lottoaddress, true },
|
{ "lotto", "lottoaddress", &lottoaddress, true },
|
||||||
|
|
||||||
/* ponzi */
|
/* fsm */
|
||||||
{ "ponzi", "ponziaddress", &ponziaddress, true },
|
{ "FSM", "FSMaddress", &FSMaddress, true },
|
||||||
|
{ "FSMcreate", "FSMcreate", &FSMcreate, true },
|
||||||
|
{ "FSMlist", "FSMlist", &FSMlist, true },
|
||||||
|
{ "FSMinfo", "FSMinfo", &FSMinfo, true },
|
||||||
|
|
||||||
/* rewards */
|
/* rewards */
|
||||||
{ "rewards", "rewardslist", &rewardslist, true },
|
{ "rewards", "rewardslist", &rewardslist, true },
|
||||||
|
|||||||
@@ -244,7 +244,10 @@ extern UniValue dicewinner(const UniValue& params, bool fHelp);
|
|||||||
extern UniValue diceloser(const UniValue& params, bool fHelp);
|
extern UniValue diceloser(const UniValue& params, bool fHelp);
|
||||||
extern UniValue dicetimeout(const UniValue& params, bool fHelp);
|
extern UniValue dicetimeout(const UniValue& params, bool fHelp);
|
||||||
extern UniValue lottoaddress(const UniValue& params, bool fHelp);
|
extern UniValue lottoaddress(const UniValue& params, bool fHelp);
|
||||||
extern UniValue ponziaddress(const UniValue& params, bool fHelp);
|
extern UniValue FSMaddress(const UniValue& params, bool fHelp);
|
||||||
|
extern UniValue FSMcreate(const UniValue& params, bool fHelp);
|
||||||
|
extern UniValue FSMlist(const UniValue& params, bool fHelp);
|
||||||
|
extern UniValue FSMinfo(const UniValue& params, bool fHelp);
|
||||||
extern UniValue auctionaddress(const UniValue& params, bool fHelp);
|
extern UniValue auctionaddress(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
extern UniValue getnewaddress(const UniValue& params, bool fHelp); // in rpcwallet.cpp
|
extern UniValue getnewaddress(const UniValue& params, bool fHelp); // in rpcwallet.cpp
|
||||||
|
|||||||
@@ -4844,7 +4844,7 @@ int32_t ensure_CCrequirements()
|
|||||||
#include "../cc/CCassets.h"
|
#include "../cc/CCassets.h"
|
||||||
#include "../cc/CCrewards.h"
|
#include "../cc/CCrewards.h"
|
||||||
#include "../cc/CCdice.h"
|
#include "../cc/CCdice.h"
|
||||||
#include "../cc/CCponzi.h"
|
#include "../cc/CCfsm.h"
|
||||||
#include "../cc/CCauction.h"
|
#include "../cc/CCauction.h"
|
||||||
#include "../cc/CClotto.h"
|
#include "../cc/CClotto.h"
|
||||||
|
|
||||||
@@ -4881,17 +4881,17 @@ UniValue lottoaddress(const UniValue& params, bool fHelp)
|
|||||||
return(CCaddress(cp,(char *)"Lotto",pubkey));
|
return(CCaddress(cp,(char *)"Lotto",pubkey));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue ponziaddress(const UniValue& params, bool fHelp)
|
UniValue FSMaddress(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
|
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
|
||||||
cp = CCinit(&C,EVAL_PONZI);
|
cp = CCinit(&C,EVAL_FSM);
|
||||||
if ( fHelp || params.size() > 1 )
|
if ( fHelp || params.size() > 1 )
|
||||||
throw runtime_error("ponziaddress [pubkey]\n");
|
throw runtime_error("FSMaddress [pubkey]\n");
|
||||||
if ( ensure_CCrequirements() < 0 )
|
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");
|
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 )
|
if ( params.size() == 1 )
|
||||||
pubkey = ParseHex(params[0].get_str().c_str());
|
pubkey = ParseHex(params[0].get_str().c_str());
|
||||||
return(CCaddress(cp,(char *)"Ponzi",pubkey));
|
return(CCaddress(cp,(char *)"FSM",pubkey));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue auctionaddress(const UniValue& params, bool fHelp)
|
UniValue auctionaddress(const UniValue& params, bool fHelp)
|
||||||
@@ -5083,6 +5083,47 @@ UniValue rewardsinfo(const UniValue& params, bool fHelp)
|
|||||||
return(RewardsInfo(fundingtxid));
|
return(RewardsInfo(fundingtxid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue FSMcreate(const UniValue& params, bool fHelp)
|
||||||
|
{
|
||||||
|
UniValue result(UniValue::VOBJ); std::string name,states,hex;
|
||||||
|
if ( fHelp || params.size() != 2 )
|
||||||
|
throw runtime_error("FSMcreate name states\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");
|
||||||
|
const CKeyStore& keystore = *pwalletMain;
|
||||||
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
name = params[0].get_str();
|
||||||
|
states = params[1].get_str();
|
||||||
|
hex = FSMcreate(0,name,states);
|
||||||
|
if ( hex.size() > 0 )
|
||||||
|
{
|
||||||
|
result.push_back(Pair("result", "success"));
|
||||||
|
result.push_back(Pair("hex", hex));
|
||||||
|
} else result.push_back(Pair("error", "couldnt create FSM transaction"));
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
UniValue FSMlist(const UniValue& params, bool fHelp)
|
||||||
|
{
|
||||||
|
uint256 tokenid;
|
||||||
|
if ( fHelp || params.size() > 0 )
|
||||||
|
throw runtime_error("FSMlist\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");
|
||||||
|
return(FSMList());
|
||||||
|
}
|
||||||
|
|
||||||
|
UniValue FSMinfo(const UniValue& params, bool fHelp)
|
||||||
|
{
|
||||||
|
uint256 FSMtxid;
|
||||||
|
if ( fHelp || params.size() != 1 )
|
||||||
|
throw runtime_error("FSMinfo fundingtxid\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");
|
||||||
|
fundingtxid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
|
return(FSMInfo(FSMtxid));
|
||||||
|
}
|
||||||
|
|
||||||
UniValue faucetinfo(const UniValue& params, bool fHelp)
|
UniValue faucetinfo(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
uint256 fundingtxid;
|
uint256 fundingtxid;
|
||||||
|
|||||||
Reference in New Issue
Block a user