Alt myprivkey method
This commit is contained in:
@@ -175,11 +175,11 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey);
|
Getscriptaddress(destaddr,vintx.vout[utxovout].scriptPubKey);
|
||||||
fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,mysingletokensaddr);
|
//fprintf(stderr,"FinalizeCCTx() vin.%d is CC %.8f -> (%s) vs %s\n",i,(double)utxovalues[i]/COIN,destaddr,mysingletokensaddr);
|
||||||
//std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl;
|
//std::cerr << "FinalizeCCtx() searching destaddr=" << destaddr << " for vin[" << i << "] satoshis=" << utxovalues[i] << std::endl;
|
||||||
if( strcmp(destaddr, myaddr) == 0 )
|
if( strcmp(destaddr, myaddr) == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr);
|
//fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr);
|
||||||
privkey = myprivkey;
|
privkey = myprivkey;
|
||||||
cond = mycond;
|
cond = mycond;
|
||||||
}
|
}
|
||||||
@@ -187,30 +187,30 @@ fprintf(stderr, "FinalizeCCTx() matched cc myaddr (%s)\n", myaddr);
|
|||||||
{
|
{
|
||||||
privkey = myprivkey;
|
privkey = myprivkey;
|
||||||
cond = mytokenscond;
|
cond = mytokenscond;
|
||||||
fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout my token addr.(%s)\n",mytokensaddr);
|
//fprintf(stderr,"FinalizeCCTx() matched dual-eval TokensCC1vout my token addr.(%s)\n",mytokensaddr);
|
||||||
}
|
}
|
||||||
else if (strcmp(destaddr, mysingletokensaddr) == 0) // if this is TokensCC1vout
|
else if (strcmp(destaddr, mysingletokensaddr) == 0) // if this is TokensCC1vout
|
||||||
{
|
{
|
||||||
privkey = myprivkey;
|
privkey = myprivkey;
|
||||||
cond = mysingletokenscond;
|
cond = mysingletokenscond;
|
||||||
fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout my token addr.(%s)\n", mytokensaddr);
|
//fprintf(stderr, "FinalizeCCTx() matched single-eval token CC1vout my token addr.(%s)\n", mytokensaddr);
|
||||||
}
|
}
|
||||||
else if ( strcmp(destaddr,unspendable) == 0 )
|
else if ( strcmp(destaddr,unspendable) == 0 )
|
||||||
{
|
{
|
||||||
privkey = unspendablepriv;
|
privkey = unspendablepriv;
|
||||||
cond = othercond;
|
cond = othercond;
|
||||||
fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable);
|
//fprintf(stderr,"FinalizeCCTx evalcode(%d) matched unspendable CC addr.(%s)\n",cp->evalcode,unspendable);
|
||||||
}
|
}
|
||||||
else if (strcmp(destaddr, unspendabletokensaddr) == 0)
|
else if (strcmp(destaddr, unspendabletokensaddr) == 0)
|
||||||
{
|
{
|
||||||
privkey = unspendablepriv;
|
privkey = unspendablepriv;
|
||||||
cond = othertokenscond;
|
cond = othertokenscond;
|
||||||
fprintf(stderr,"FinalizeCCTx() matched unspendabletokensaddr dual/three-eval CC addr.(%s)\n",unspendabletokensaddr);
|
//fprintf(stderr,"FinalizeCCTx() matched unspendabletokensaddr dual/three-eval CC addr.(%s)\n",unspendabletokensaddr);
|
||||||
}
|
}
|
||||||
// check if this is the 2nd additional evalcode + 'unspendable' cc addr:
|
// check if this is the 2nd additional evalcode + 'unspendable' cc addr:
|
||||||
else if ( strcmp(destaddr, cp->unspendableaddr2) == 0)
|
else if ( strcmp(destaddr, cp->unspendableaddr2) == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2);
|
//fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2);
|
||||||
privkey = cp->unspendablepriv2;
|
privkey = cp->unspendablepriv2;
|
||||||
if( othercond2 == 0 )
|
if( othercond2 == 0 )
|
||||||
othercond2 = MakeCCcond1(cp->unspendableEvalcode2, cp->unspendablepk2);
|
othercond2 = MakeCCcond1(cp->unspendableEvalcode2, cp->unspendablepk2);
|
||||||
@@ -219,7 +219,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s unspendable2!\n",cp->unspendableaddr2)
|
|||||||
// check if this is 3rd additional evalcode + 'unspendable' cc addr:
|
// check if this is 3rd additional evalcode + 'unspendable' cc addr:
|
||||||
else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 )
|
else if ( strcmp(destaddr,cp->unspendableaddr3) == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3);
|
//fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3);
|
||||||
privkey = cp->unspendablepriv3;
|
privkey = cp->unspendablepriv3;
|
||||||
if( othercond3 == 0 )
|
if( othercond3 == 0 )
|
||||||
othercond3 = MakeCCcond1(cp->unspendableEvalcode3, cp->unspendablepk3);
|
othercond3 = MakeCCcond1(cp->unspendableEvalcode3, cp->unspendablepk3);
|
||||||
@@ -228,7 +228,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s unspendable3!\n",cp->unspendableaddr3)
|
|||||||
// check if this is spending from 1of2 cc coins addr:
|
// check if this is spending from 1of2 cc coins addr:
|
||||||
else if (strcmp(cp->coins1of2addr, destaddr) == 0)
|
else if (strcmp(cp->coins1of2addr, destaddr) == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr);
|
//fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr);
|
||||||
privkey = cp->coins1of2priv;//myprivkey;
|
privkey = cp->coins1of2priv;//myprivkey;
|
||||||
if (othercond1of2 == 0)
|
if (othercond1of2 == 0)
|
||||||
othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]);
|
othercond1of2 = MakeCCcond1of2(cp->evalcode, cp->coins1of2pk[0], cp->coins1of2pk[1]);
|
||||||
@@ -236,7 +236,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s unspendable1of2!\n",cp->coins1of2addr)
|
|||||||
}
|
}
|
||||||
else if ( strcmp(CC1of2CCaddr,destaddr) == 0 )
|
else if ( strcmp(CC1of2CCaddr,destaddr) == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr);
|
//fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr);
|
||||||
privkey = unspendablepriv;
|
privkey = unspendablepriv;
|
||||||
if (condCC2 == 0)
|
if (condCC2 == 0)
|
||||||
condCC2 = MakeCCcond1of2(cp->evalcode,unspendablepk,unspendablepk);
|
condCC2 = MakeCCcond1of2(cp->evalcode,unspendablepk,unspendablepk);
|
||||||
@@ -245,7 +245,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s CC1of2CCaddr!\n",CC1of2CCaddr);
|
|||||||
// check if this is spending from 1of2 cc tokens addr:
|
// check if this is spending from 1of2 cc tokens addr:
|
||||||
else if (strcmp(cp->tokens1of2addr, destaddr) == 0)
|
else if (strcmp(cp->tokens1of2addr, destaddr) == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr);
|
//fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2addr);
|
||||||
privkey = cp->tokens1of2priv;//myprivkey;
|
privkey = cp->tokens1of2priv;//myprivkey;
|
||||||
if (othercond1of2tokens == 0)
|
if (othercond1of2tokens == 0)
|
||||||
// NOTE: if additionalEvalcode2 is not set then it is dual-eval cc else three-eval cc
|
// NOTE: if additionalEvalcode2 is not set then it is dual-eval cc else three-eval cc
|
||||||
@@ -293,6 +293,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr,"vini.%d has CC signing error address.(%s) %s\n",i,destaddr,EncodeHexTx(mtx).c_str());
|
fprintf(stderr,"vini.%d has CC signing error address.(%s) %s\n",i,destaddr,EncodeHexTx(mtx).c_str());
|
||||||
|
memset(myprivkey,0,sizeof(myprivkey));
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -320,6 +321,7 @@ fprintf(stderr,"FinalizeCCTx() matched %s cp->tokens1of2addr!\n", cp->tokens1of2
|
|||||||
cc_free(mysingletokenscond);
|
cc_free(mysingletokenscond);
|
||||||
if ( othertokenscond != 0 )
|
if ( othertokenscond != 0 )
|
||||||
cc_free(othertokenscond);
|
cc_free(othertokenscond);
|
||||||
|
memset(myprivkey,0,sizeof(myprivkey));
|
||||||
std::string strHex = EncodeHexTx(mtx);
|
std::string strHex = EncodeHexTx(mtx);
|
||||||
if ( strHex.size() > 0 )
|
if ( strHex.size() > 0 )
|
||||||
return(strHex);
|
return(strHex);
|
||||||
|
|||||||
@@ -442,13 +442,16 @@ std::vector<uint8_t> Mypubkey()
|
|||||||
return(pubkey);
|
return(pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern CKey NSPV_key;
|
|
||||||
bool Myprivkey(uint8_t myprivkey[])
|
bool Myprivkey(uint8_t myprivkey[])
|
||||||
{
|
{
|
||||||
char coinaddr[64],checkaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; uint8_t buf33[33];
|
char coinaddr[64],checkaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; uint8_t buf33[33];
|
||||||
if ( KOMODO_NSPV != 0 )
|
if ( KOMODO_NSPV != 0 )
|
||||||
{
|
{
|
||||||
NSPV_key.SetKey32(myprivkey);
|
vchSecret = DecodeSecret(NSPV_wifstr);
|
||||||
|
for (i=0; i<32; i++)
|
||||||
|
fprintf(stderr,"%02x",myprivkey[i]);
|
||||||
|
fprintf(stderr," myprivkey\n");
|
||||||
|
memset(vchSecret.begin(),0,32);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG) != 0 )
|
if ( Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG) != 0 )
|
||||||
@@ -465,6 +468,7 @@ bool Myprivkey(uint8_t myprivkey[])
|
|||||||
if ( pwalletMain->GetKey(keyID,vchSecret) != 0 )
|
if ( pwalletMain->GetKey(keyID,vchSecret) != 0 )
|
||||||
{
|
{
|
||||||
memcpy(myprivkey,vchSecret.begin(),32);
|
memcpy(myprivkey,vchSecret.begin(),32);
|
||||||
|
memset(vchSecret.begin(),0,32);
|
||||||
if ( 0 )
|
if ( 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<32; i++)
|
for (i=0; i<32; i++)
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
|
|||||||
rewardsum += rewards;
|
rewardsum += rewards;
|
||||||
}
|
}
|
||||||
//char coinaddr[64];
|
//char coinaddr[64];
|
||||||
//Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey);
|
//Getscriptaddress(coinaddr,tx.vout[0].scriptPubKey); causes crash??
|
||||||
//fprintf(stderr,"%s txid.%s vs hash.%s\n",coinaddr,txid.GetHex().c_str(),tx.GetHash().GetHex().c_str());
|
//fprintf(stderr,"%s txid.%s vs hash.%s\n",coinaddr,txid.GetHex().c_str(),tx.GetHash().GetHex().c_str());
|
||||||
|
|
||||||
if ( skipvalidation == 0 )
|
if ( skipvalidation == 0 )
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
vchSig = CCSigVec(cc);
|
vchSig = CCSigVec(cc);
|
||||||
|
if ( KOMODO_NSPV != 0 )
|
||||||
|
memset(key.begin(),0,32);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -98,7 +100,8 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
|
|||||||
}
|
}
|
||||||
|
|
||||||
vchSig.push_back((unsigned char)nHashType);
|
vchSig.push_back((unsigned char)nHashType);
|
||||||
|
if ( KOMODO_NSPV != 0 )
|
||||||
|
memset(key.begin(),0,32);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user