Pending object

This commit is contained in:
jl777
2019-01-29 21:48:26 -11:00
parent 70df4c1acf
commit 3ba832b6bc
3 changed files with 19 additions and 3 deletions

View File

@@ -134,6 +134,7 @@ int32_t CCgetspenttxid(uint256 &spenttxid,int32_t &vini,int32_t &height,uint256
void CCclearvars(struct CCcontract_info *cp);
UniValue CClib(struct CCcontract_info *cp,char *method,cJSON *params);
UniValue CClib_info(struct CCcontract_info *cp);
CBlockIndex *komodo_blockindex(uint256 hash);
static const uint256 zeroid;
bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock);

View File

@@ -667,7 +667,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{
UniValue result(UniValue::VOBJ); int32_t numvouts; char str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; char unsolved[82];
UniValue result(UniValue::VOBJ); int32_t numvouts; char str[65],*txidstr; uint256 txid,hashBlock; CTransaction tx; char unsolved[82]; CBlockIndex *pindex;
if ( params != 0 )
{
result.push_back(Pair("result","success"));
@@ -687,6 +687,8 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' )
{
result.push_back(Pair("result","success"));
if ( (pindex= komodo_blockindex(hashBlock)) != 0 )
result.push_back(Pair("height",pindex->nHeight));
result.push_back(Pair("amount",ValueFromAmount(tx.vout[1].nValue)));
result.push_back(Pair("unsolved",unsolved));
}
@@ -716,7 +718,7 @@ UniValue sudoku_txidinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{
UniValue result(UniValue::VOBJ),a(UniValue::VARR);
char coinaddr[64],unsolved[82]; int64_t nValue,total=0; uint256 txid,hashBlock; CTransaction tx; int32_t vout,numvouts; CPubKey sudokupk;
char coinaddr[64],unsolved[82]; int64_t nValue,total=0; uint256 txid,hashBlock; CTransaction tx; int32_t vout,numvouts; CPubKey sudokupk; CBlockIndex *pindex;
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
sudokupk = GetUnspendable(cp,0);
GetCCaddress(cp,coinaddr,sudokupk);
@@ -734,7 +736,12 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{
if ( sudoku_genopreturndecode(unsolved,tx.vout[numvouts-1].scriptPubKey) == 'G' )
{
a.push_back(txid.GetHex());
UniValue obj(UniValue::VOBJ);
if ( (pindex= komodo_blockindex(hashBlock)) != 0 )
obj.push_back(Pair("height",pindex->nHeight));
obj.push_back(Pair("amount",ValueFromAmount(tx.vout[1].nValue)));
obj.push_back(Pair("txid",txid.GetHex()));
a.push_back(obj);
total += tx.vout[1].nValue;
}
}

View File

@@ -1033,6 +1033,14 @@ int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,in
return(depth);
}
CBlockIndex *komodo_blockindex(uint256 hash)
{
BlockMap::const_iterator it; CBlockIndex *pindex = 0;
if ( (it = mapBlockIndex.find(hash)) != mapBlockIndex.end() )
pindex = it->second;
return(pindex);
}
int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash)
{
int32_t notarized_height,MoMdepth; uint256 MoM,notarized_hash,notarized_desttxid; CBlockIndex *notary,*pindex;