MarmaraSignature

This commit is contained in:
jl777
2019-01-20 23:31:30 -11:00
parent 00151d02b0
commit 824325ac28
2 changed files with 40 additions and 12 deletions

View File

@@ -500,7 +500,34 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height)
return(result);
}
// jl777: decide on what unlockht settlement change should have
int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew);
{
uint256 txid,hashBlock; uint8_t *ptr; int32_t i,siglen,vout,numvouts; CTransaction tx; std::string rawtx; CPubKey mypk; std::vector<CPubKey> pubkeys; struct CCcontract_info *cp,C; uint64_t txfee
txfee = 10000;
vout = txNew.vin[0].prevout.n;
if ( GetTransaction(txNew.vin[0].prevout.hash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 && vout < numvouts )
{
cp = CCinit(&C,EVAL_MARMARA);
mypk = pubkey2pk(Mypubkey());
mtx.vout.resize(2);
mtx.vout[1].scriptPubKey = tx.vout[numvouts - 1].scriptPubKey;
mtx.vout[1].nValue = 0;
pubkeys.push_back(mypk);
rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,tx.vout[numvouts - 1].scriptPubKey,pubkeys);
if ( rawtx.size() > 0 )
{
siglen = mtx.vin[0].scriptSig.size();
ptr = mtx.vin[0].scriptSig.data();
for (i=0; i<siglen; i++)
utxosig[i] = ptr[i];
fprintf(stderr,"got signed rawtx.%s siglen.%d\n",rawtx.c_str(),siglen);
return(siglen);
}
}
return(0);
}
// jl777: decide on what unlockht settlement change should have -> from utxo making change
UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid)
{

View File

@@ -2081,6 +2081,8 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod
return(0);
}
int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew);
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig)
{
static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime;
@@ -2264,22 +2266,21 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
if ( ASSETCHAINS_MARMARA == 0 )
{
signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId);
}
else
{
fprintf(stderr,"add opreturn and CCFinalizetx\n");
// add opreturn
// signSuccess = CCFinalizetx(...)
}
if (!signSuccess)
fprintf(stderr,"failed to create signature\n");
else
{
UpdateTransaction(txNew,0,sigdata);
ptr = (uint8_t *)&sigdata.scriptSig[0];
siglen = sigdata.scriptSig.size();
for (i=0; i<siglen; i++)
utxosig[i] = ptr[i];//, fprintf(stderr,"%02x",ptr[i]);
}
else
{
fprintf(stderr,"add opreturn and CCFinalizetx\n");
siglen = MarmaraSignature(utxosig,txNew);
}
if (!signSuccess)
fprintf(stderr,"failed to create signature\n");
else
{
//fprintf(stderr," siglen.%d\n",siglen);
//fprintf(stderr,"best %u from %u, gap %d lag.%d\n",earliest,*blocktimep,(int32_t)(earliest - *blocktimep),(int32_t)(time(NULL) - *blocktimep));
*blocktimep = earliest;