diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c350e0e28..ef0088330 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -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)