- fix
This commit is contained in:
@@ -27,6 +27,6 @@ std::string ChannelClose(uint64_t txfee,uint256 opentxid);
|
|||||||
std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid);
|
std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid);
|
||||||
|
|
||||||
// CCcustom
|
// CCcustom
|
||||||
UniValue ChannelsInfo(char *);
|
UniValue ChannelsInfo(uint256 opentxid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -405,7 +405,7 @@ int64_t CCduration(int32_t &numblocks,uint256 txid)
|
|||||||
}
|
}
|
||||||
numblocks = (pindex->nHeight - txheight);
|
numblocks = (pindex->nHeight - txheight);
|
||||||
duration = (pindex->nTime - txtime);
|
duration = (pindex->nTime - txtime);
|
||||||
fprintf(stderr,"duration %d (%u - %u) numblocks %d (%d - %d)\n",(int32_t)duration,(uint32_t)pindex->nTime,txtime,numblocks,pindex->nHeight,txheight);
|
//fprintf(stderr,"duration %d (%u - %u) numblocks %d (%d - %d)\n",(int32_t)duration,(uint32_t)pindex->nTime,txtime,numblocks,pindex->nHeight,txheight);
|
||||||
return(duration);
|
return(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -681,7 +681,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid)
|
|||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue ChannelsInfo(char *CCaddr)
|
UniValue ChannelsInfo(uint256 channeltxid)
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ); CTransaction tx,opentx; uint256 txid,tmp_txid,hashBlock,param3,opentxid,hashchain,prevtxid;
|
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[64],addr[64],str1[256],str2[64]; int32_t vout,numvouts,param1,numpayments;
|
||||||
@@ -691,7 +691,7 @@ UniValue ChannelsInfo(char *CCaddr)
|
|||||||
result.push_back(Pair("result","success"));
|
result.push_back(Pair("result","success"));
|
||||||
cp = CCinit(&C,EVAL_CHANNELS);
|
cp = CCinit(&C,EVAL_CHANNELS);
|
||||||
mypk = pubkey2pk(Mypubkey());
|
mypk = pubkey2pk(Mypubkey());
|
||||||
if (strcmp(CCaddr,"")==0)
|
if (channeltxid==zeroid)
|
||||||
{
|
{
|
||||||
result.push_back(Pair("name","Channels Info"));
|
result.push_back(Pair("name","Channels Info"));
|
||||||
GetCCaddress(cp,myCCaddr,mypk);
|
GetCCaddress(cp,myCCaddr,mypk);
|
||||||
@@ -704,10 +704,10 @@ UniValue ChannelsInfo(char *CCaddr)
|
|||||||
nValue = (int64_t)it->second;
|
nValue = (int64_t)it->second;
|
||||||
if ( (vout == 1 || vout == 2) && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 )
|
if ( (vout == 1 || vout == 2) && nValue == 10000 && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 )
|
||||||
{
|
{
|
||||||
if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'O')
|
if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O')
|
||||||
{
|
{
|
||||||
GetCCaddress1of2(cp,addr,srcpub,destpub);
|
GetCCaddress1of2(cp,addr,srcpub,destpub);
|
||||||
sprintf(str1,"%s - %lld payments of %lld satoshi",addr,(long long)param1,(long long)param2);
|
sprintf(str1,"%s - %lld payments of %lld satoshi - %s",addr,(long long)param1,(long long)param2,tx.GetHash().ToString().c_str());
|
||||||
result.push_back(Pair("Channel", str1));
|
result.push_back(Pair("Channel", str1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -715,44 +715,48 @@ UniValue ChannelsInfo(char *CCaddr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(str1,"Channel %s",CCaddr);
|
if (GetTransaction(channeltxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 &&
|
||||||
result.push_back(Pair("name",str1));
|
(DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'O'))
|
||||||
strcpy(myCCaddr,CCaddr);
|
|
||||||
SetCCtxids(txids,myCCaddr);
|
|
||||||
prevtxid=zeroid;
|
|
||||||
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=txids.begin(); it!=txids.end(); it++)
|
|
||||||
{
|
{
|
||||||
//int height = it->first.blockHeight;
|
GetCCaddress1of2(cp,addr,srcpub,destpub);
|
||||||
txid = it->first.txhash;
|
sprintf(str1,"Channel %s",addr);
|
||||||
nValue = (int64_t)it->second;
|
result.push_back(Pair("name",str1));
|
||||||
if (txid!=prevtxid && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 )
|
SetCCtxids(txids,addr);
|
||||||
|
prevtxid=zeroid;
|
||||||
|
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=txids.begin(); it!=txids.end(); it++)
|
||||||
{
|
{
|
||||||
if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'O')
|
|
||||||
|
txid = it->first.txhash;
|
||||||
|
nValue = (int64_t)it->second;
|
||||||
|
if (txid!=prevtxid && GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 )
|
||||||
{
|
{
|
||||||
sprintf(str1,"%lld payments of %lld satoshi",(long long)param1,(long long)param2);
|
if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O' && tx.GetHash()==channeltxid)
|
||||||
result.push_back(Pair("Open", str1));
|
|
||||||
}
|
|
||||||
else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'P')
|
|
||||||
{
|
|
||||||
if (GetTransaction(opentxid,opentx,hashBlock,false) != 0 && (numvouts=opentx.vout.size()) > 0 && DecodeChannelsOpRet(opentx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,numpayments,payment,hashchain) == 'O')
|
|
||||||
{
|
{
|
||||||
Getscriptaddress(str2,tx.vout[3].scriptPubKey);
|
sprintf(str1,"%lld payments of %lld satoshi",(long long)param1,(long long)param2);
|
||||||
sprintf(str1,"%lld satoshi to %s, %lld payments left",(long long)(param2*payment),str2,(long long)param1);
|
result.push_back(Pair("Open", str1));
|
||||||
result.push_back(Pair("Payment",str1));
|
}
|
||||||
|
else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'P' && opentxid==channeltxid)
|
||||||
|
{
|
||||||
|
if (GetTransaction(opentxid,opentx,hashBlock,false) != 0 && (numvouts=opentx.vout.size()) > 0 && DecodeChannelsOpRet(opentx.vout[numvouts-1].scriptPubKey,tmp_txid,srcpub,destpub,numpayments,payment,hashchain) == 'O')
|
||||||
|
{
|
||||||
|
Getscriptaddress(str2,tx.vout[3].scriptPubKey);
|
||||||
|
sprintf(str1,"%lld satoshi to %s, %lld payments left",(long long)(param2*payment),str2,(long long)param1);
|
||||||
|
result.push_back(Pair("Payment",str1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'C' && opentxid==channeltxid)
|
||||||
|
{
|
||||||
|
result.push_back(Pair("Close","channel"));
|
||||||
|
}
|
||||||
|
else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'R' && opentxid==channeltxid)
|
||||||
|
{
|
||||||
|
Getscriptaddress(str2,tx.vout[2].scriptPubKey);
|
||||||
|
sprintf(str1,"%lld satoshi back to %s",(long long)(param1*param2),str2);
|
||||||
|
result.push_back(Pair("Refund",str1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'C')
|
prevtxid=txid;
|
||||||
{
|
|
||||||
result.push_back(Pair("Close","channel"));
|
|
||||||
}
|
|
||||||
else if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,opentxid,srcpub,destpub,param1,param2,param3) == 'R')
|
|
||||||
{
|
|
||||||
Getscriptaddress(str2,tx.vout[2].scriptPubKey);
|
|
||||||
sprintf(str1,"%lld satoshi back to %s",(long long)(param1*param2),str2);
|
|
||||||
result.push_back(Pair("Refund",str1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
prevtxid=txid;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
|
|||||||
@@ -5124,15 +5124,15 @@ UniValue tokenaddress(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
UniValue channelsinfo(const UniValue& params, bool fHelp)
|
UniValue channelsinfo(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
char addr[100];
|
uint256 opentxid;
|
||||||
if ( fHelp || params.size() > 1 )
|
if ( fHelp || params.size() > 1 )
|
||||||
throw runtime_error("channelsinfo\n");
|
throw runtime_error("channelsinfo [opentxid]\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");
|
||||||
strcpy(addr,"");
|
opentxid=zeroid;
|
||||||
if (params.size() > 0 && !params[0].isNull() && !params[0].get_str().empty())
|
if (params.size() > 0 && !params[0].isNull() && !params[0].get_str().empty())
|
||||||
strcpy(addr,params[0].get_str().c_str());
|
opentxid = Parseuint256((char *)params[0].get_str().c_str());
|
||||||
return(ChannelsInfo(addr));
|
return(ChannelsInfo(opentxid));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue channelsopen(const UniValue& params, bool fHelp)
|
UniValue channelsopen(const UniValue& params, bool fHelp)
|
||||||
|
|||||||
Reference in New Issue
Block a user