This commit is contained in:
jl777
2018-04-09 14:35:50 +03:00
parent 21965c3f7a
commit 1e7ed9289b

View File

@@ -2691,6 +2691,7 @@ UniValue listunspent(const UniValue& params, bool fHelp)
return results;
}
#include "script/sign.h"
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
int32_t komodo_staked(uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig)
@@ -2754,8 +2755,18 @@ int32_t komodo_staked(uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,ui
}
fprintf(stderr,"(%s) %s/v%d nValue %.8f locktime.%u txheight.%d pindexht.%d\n",CBitcoinAddress(address).ToString().c_str(),out.tx->GetHash().GetHex().c_str(),out.i,(double)nValue/COIN,locktime,txheight,pindex->nHeight);
}
bool signSuccess; SignatureData sigdata; uint8_t *ptr;
bool signSuccess; SignatureData sigdata; uint8_t *ptr; uint256 revtxid,utxotxid;
auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus());
CMutableTransaction txNew = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1);
txNew.vin.resize(1);
txNew.vout.resize(1);
for (i=0; i<32; i++)
((uint8_t *)&revtxid)[i] = ((uint8_t *)utxotxidp)[31 - i];
txNew.vin[0].prevout.hash = revtxid;
txNew.vin[0].prevout.n = *utxovoutp;
txNew.vout[0].scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG;
txNew.vout[0].nValue = nValue - txfees;
txNew.nLockTime = (uint32_t)chainActive.Tip()->nTime + chainparams.GetConsensus().nPowTargetSpacing; // set to a time close to now
CTransaction txNewConst(txNew);
signSuccess = ProduceSignature(TransactionSignatureCreator(this, &txNewConst, 0, nValue, SIGHASH_ALL), out.tx->vout[out.i].scriptPubKey, sigdata, consensusBranchId);
if (!signSuccess)