This commit is contained in:
Mihailo Milenkovic
2018-10-29 17:52:30 +01:00
parent a19d3e7881
commit 6721141bc0
2 changed files with 9 additions and 9 deletions

View File

@@ -683,7 +683,7 @@ cJSON *addmultisignature(char *refcoin,char *acname,char *signeraddr,char *rawtx
return(0); return(0);
} }
char *get_gatewaysmultisig(char *refcoin,char *acname,char *txidaddr) char *get_gatewaysmultisig(char *refcoin,char *acname,char *txidaddr,int32_t *K)
{ {
char *retstr,*hexstr,*hex=0; cJSON *retjson; char *retstr,*hexstr,*hex=0; cJSON *retjson;
if ( (retjson= get_komodocli("KMD",&retstr,acname,"gatewaysmultisig",txidaddr,"","","")) != 0 ) if ( (retjson= get_komodocli("KMD",&retstr,acname,"gatewaysmultisig",txidaddr,"","","")) != 0 )
@@ -889,7 +889,7 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t
} }
else else
{ {
if ( (rawtx= get_gatewaysmultisig(refcoin,acname,txidaddr)) == 0 ) if ( (rawtx= get_gatewaysmultisig(refcoin,acname,txidaddr,&K)) == 0 )
{ {
rawtx = createmultisig(refcoin,"",depositaddr,signeraddr,withdrawaddr,satoshis); rawtx = createmultisig(refcoin,"",depositaddr,signeraddr,withdrawaddr,satoshis);
} }
@@ -908,8 +908,8 @@ void update_gatewayspending(char *refcoin,char *acname,char *bindtxidstr,int32_t
} }
else if ( jint(clijson,"partialtx") != 0 ) else if ( jint(clijson,"partialtx") != 0 )
{ {
K=gatewayspartialsign(refcoin,acname,origtxid,jstr(clijson,"hex")); gatewayspartialsign(refcoin,acname,origtxid,jstr(clijson,"hex"));
fprintf(stderr,"%d of %d partialtx %s sent\n",K,N,bits256_str(str,txid)); fprintf(stderr,"%d of %d partialtx %s sent\n",K+1,N,bits256_str(str,txid));
} }
free_json(clijson); free_json(clijson);
} }

View File

@@ -922,7 +922,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin)
std::string GatewaysMultisig(char *txidaddr) std::string GatewaysMultisig(char *txidaddr)
{ {
std::string parthex,hex,refcoin; uint256 txid,hashBlock; CTransaction tx; int32_t i,maxK,K,numvouts; CPubKey signerpk; std::string parthex,hex,refcoin; uint256 txid,hashBlock; CTransaction tx; int32_t i,maxK,K,numvouts; CPubKey signerpk;
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; UniValue result(UniValue::VOBJ);
SetCCunspents(unspentOutputs,txidaddr); SetCCunspents(unspentOutputs,txidaddr);
if (unspentOutputs.size()==0) return (""); if (unspentOutputs.size()==0) return ("");
@@ -949,15 +949,15 @@ std::string GatewaysMultisig(char *txidaddr)
} }
} }
if (maxK>0) return(parthex); result.push_back(Pair("hex",parthex));
else return (""); result.push_back(Pair("number_of_signs",K));
} }
std::string GatewaysPartialSign(uint64_t txfee,uint256 txid,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,txidaddrpk,signerpk; struct CCcontract_info *cp,C; CTransaction tx; 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]; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; char txidaddr[65];
int32_t maxK,K=0; uint256 tmptxid,parttxid,hashBlock; int32_t maxK,K=0; uint256 tmptxid,parttxid,hashBlock;
cp = CCinit(&C,EVAL_GATEWAYS); cp = CCinit(&C,EVAL_GATEWAYS);
if ( txfee == 0 ) if ( txfee == 0 )
txfee = 5000; txfee = 5000;
@@ -985,6 +985,6 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 txid,std::string refcoin,
} }
mtx.vout.push_back(CTxOut(5000,CScript() << ParseHex(HexStr(txidaddrpk)) << OP_CHECKSIG)); mtx.vout.push_back(CTxOut(5000,CScript() << ParseHex(HexStr(txidaddrpk)) << OP_CHECKSIG));
opret << OP_RETURN << E_MARSHAL(ss << cp->evalcode << 'P' << K+1 << mypk << refcoin << hex); opret << OP_RETURN << E_MARSHAL(ss << cp->evalcode << 'P' << K+1 << mypk << refcoin << hex);
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret));
} }