Fix
This commit is contained in:
@@ -28,7 +28,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin
|
||||
UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin);
|
||||
std::string GatewaysMarkdone(uint64_t txfee,uint256 withdrawtxid,std::string refcoin,uint256 cointxid);
|
||||
std::string GatewaysMultisig(char *txidaddr);
|
||||
std::string GatewaysPartialSign(uint64_t txfee,char* txidaddr,std::string refcoin, std::string hex);
|
||||
std::string GatewaysPartialSign(uint64_t txfee,uint256 txidaddr,std::string refcoin, std::string hex);
|
||||
|
||||
// CCcustom
|
||||
UniValue GatewaysInfo(uint256 bindtxid);
|
||||
|
||||
@@ -64,7 +64,7 @@ Possible third iteration:
|
||||
|
||||
int64_t IsChannelsvout(struct CCcontract_info *cp,const CTransaction& tx,CPubKey srcpub, CPubKey destpub,int32_t v)
|
||||
{
|
||||
char destaddr[64],channeladdr[64];
|
||||
char destaddr[65],channeladdr[65];
|
||||
|
||||
GetCCaddress1of2(cp,channeladdr,srcpub,destpub);
|
||||
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
||||
@@ -77,7 +77,7 @@ int64_t IsChannelsvout(struct CCcontract_info *cp,const CTransaction& tx,CPubKey
|
||||
|
||||
int64_t IsChannelsMarkervout(struct CCcontract_info *cp,const CTransaction& tx,CPubKey srcpub,int32_t v)
|
||||
{
|
||||
char destaddr[64],ccaddr[64];
|
||||
char destaddr[65],ccaddr[65];
|
||||
|
||||
GetCCaddress(cp,ccaddr,srcpub);
|
||||
if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 )
|
||||
@@ -364,7 +364,7 @@ bool ChannelsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
|
||||
|
||||
int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, CTransaction openTx, uint256 &prevtxid)
|
||||
{
|
||||
char coinaddr[64]; int64_t param2,totalinputs = 0,numvouts; uint256 txid=zeroid,tmp_txid,hashBlock,param3; CTransaction tx; int32_t param1;
|
||||
char coinaddr[65]; int64_t param2,totalinputs = 0,numvouts; uint256 txid=zeroid,tmp_txid,hashBlock,param3; CTransaction tx; int32_t param1;
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||
CPubKey srcpub,destpub;
|
||||
uint8_t myprivkey[32];
|
||||
@@ -692,7 +692,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid)
|
||||
UniValue ChannelsInfo(uint256 channeltxid)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ); CTransaction tx,opentx; uint256 txid,tmp_txid,hashBlock,param3,opentxid,hashchain,prevtxid;
|
||||
struct CCcontract_info *cp,C; char myCCaddr[64],addr[64],str1[256],str2[64]; int32_t vout,numvouts,param1,numpayments;
|
||||
struct CCcontract_info *cp,C; char myCCaddr[65],addr[65],str1[256],str2[65]; int32_t vout,numvouts,param1,numpayments;
|
||||
int64_t nValue,param2,payment; CPubKey srcpub,destpub,mypk;
|
||||
std::vector<std::pair<CAddressIndexKey, CAmount> > txids;
|
||||
|
||||
|
||||
@@ -660,10 +660,10 @@ char *get_gatewaysmultisig(char *refcoin,char *acname,char *txidaddr)
|
||||
return(hex);
|
||||
}
|
||||
|
||||
int32_t gatewayspartialsign(char *refcoin,char *acname,char *txidaddr,char *hex)
|
||||
int32_t gatewayspartialsign(char *refcoin,char *acname,bits256 txid,char *hex)
|
||||
{
|
||||
char str[65],str2[65],*retstr; cJSON *retjson;
|
||||
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayspartialsign",txidaddr,refcoin,hex,"")) != 0 )
|
||||
char str[65],*retstr; cJSON *retjson;
|
||||
if ( (retjson= get_komodocli(refcoin,&retstr,acname,"gatewayspartialsign",bits256_str(str,txid),refcoin,hex,"")) != 0 )
|
||||
{
|
||||
komodobroadcast(refcoin,acname,retjson);
|
||||
return(jint(retjson,"rank"));
|
||||
@@ -859,7 +859,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t
|
||||
}
|
||||
else if ( jint(clijson,"partialtx") != 0 )
|
||||
{
|
||||
K=gatewayspartialsign(refcoin,acname,txidaddr,jstr(clijson,"hex"));
|
||||
K=gatewayspartialsign(refcoin,acname,origtxid,jstr(clijson,"hex"));
|
||||
fprintf(stderr,"%d of %d partialtx %s sent\n",K,N,bits256_str(str,txid));
|
||||
}
|
||||
free_json(clijson);
|
||||
|
||||
@@ -940,16 +940,16 @@ std::string GatewaysMultisig(char *txidaddr)
|
||||
else return ("");
|
||||
}
|
||||
|
||||
std::string GatewaysPartialSign(uint64_t txfee,char* txidaddr,std::string refcoin, std::string hex)
|
||||
std::string GatewaysPartialSign(uint64_t txfee,uint256 txid,std::string refcoin, std::string hex)
|
||||
{
|
||||
CMutableTransaction mtx; CScript opret; CPubKey mypk,gatewayspk,signerpk; struct CCcontract_info *cp,C; CTransaction tx;
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||
int32_t maxK,K; uint256 txid,parttxid,hashBlock;
|
||||
CMutableTransaction mtx; CScript opret; CPubKey mypk,txidaddrpk,signerpk; struct CCcontract_info *cp,C; CTransaction tx;
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; char txidaddr[65];
|
||||
int32_t maxK,K; uint256 tmptxid,parttxid,hashBlock;
|
||||
cp = CCinit(&C,EVAL_GATEWAYS);
|
||||
if ( txfee == 0 )
|
||||
txfee = 5000;
|
||||
mypk = pubkey2pk(Mypubkey());
|
||||
gatewayspk = GetUnspendable(cp,0);
|
||||
txidaddrpk=CCtxidaddr(txidaddr,txid);
|
||||
SetCCunspents(unspentOutputs,txidaddr);
|
||||
if (unspentOutputs.size()==0)
|
||||
{
|
||||
@@ -961,18 +961,18 @@ std::string GatewaysPartialSign(uint64_t txfee,char* txidaddr,std::string refcoi
|
||||
maxK=0;
|
||||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++)
|
||||
{
|
||||
txid = it->first.txhash;
|
||||
if (GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && DecodeGatewaysPartialOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,K,signerpk,refcoin,hex) == 'P' && K>maxK )
|
||||
tmptxid = it->first.txhash;
|
||||
if (GetTransaction(tmptxid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && DecodeGatewaysPartialOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,K,signerpk,refcoin,hex) == 'P' && K>maxK )
|
||||
{
|
||||
maxK=K;
|
||||
parttxid=txid;
|
||||
parttxid=tmptxid;
|
||||
}
|
||||
}
|
||||
if (maxK>0) mtx.vin.push_back(CTxIn(parttxid,0,CScript()));
|
||||
else fprintf(stderr,"Error finding previous partial tx\n");
|
||||
}
|
||||
|
||||
mtx.vout.push_back(CTxOut(5000,txidaddr));
|
||||
mtx.vout.push_back(CTxOut(5000,CScript() << ParseHex(HexStr(txidaddrpk)) << OP_CHECKSIG));
|
||||
opret << OP_RETURN << E_MARSHAL(ss << cp->evalcode << 'P' << K << mypk << refcoin << hex);
|
||||
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret));
|
||||
}
|
||||
|
||||
@@ -5611,17 +5611,17 @@ UniValue gatewaysmultisig(const UniValue& params, bool fHelp)
|
||||
|
||||
UniValue gatewayspartialsign(const UniValue& params, bool fHelp)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ); std::string coin,parthex,hex; char *txidaddr;
|
||||
UniValue result(UniValue::VOBJ); std::string coin,parthex,hex; uint256 txid;
|
||||
if ( fHelp || params.size() != 3 )
|
||||
throw runtime_error("gatewayspartialsign txidaddr refcoin hex\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);
|
||||
txidaddr = (char *)params[0].get_str().c_str();
|
||||
txid = Parseuint256((char *)params[0].get_str().c_str());
|
||||
coin = params[1].get_str();
|
||||
coin = params[2].get_str();
|
||||
hex = GatewaysPartialSign(0,txidaddr,coin,parthex);
|
||||
parthex = params[2].get_str();
|
||||
hex = GatewaysPartialSign(0,txid,coin,parthex);
|
||||
if ( hex.size() > 0 )
|
||||
{
|
||||
result.push_back(Pair("result", "success"));
|
||||
|
||||
Reference in New Issue
Block a user