Very partial CC signing support
This commit is contained in:
@@ -289,6 +289,7 @@ void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex
|
|||||||
int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs);
|
int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs);
|
||||||
int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs);
|
int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs);
|
||||||
int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag);
|
int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag);
|
||||||
|
bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey);
|
||||||
|
|
||||||
// curve25519 and sha256
|
// curve25519 and sha256
|
||||||
bits256 curve25519_shared(bits256 privkey,bits256 otherpub);
|
bits256 curve25519_shared(bits256 privkey,bits256 otherpub);
|
||||||
|
|||||||
@@ -150,8 +150,16 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
|
|||||||
utxovout = mtx.vin[i].prevout.n;
|
utxovout = mtx.vin[i].prevout.n;
|
||||||
if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 )
|
if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 )
|
||||||
{
|
{
|
||||||
if ( SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey) == 0 )
|
if ( KOMODO_NSPV == 0 )
|
||||||
fprintf(stderr,"signing error for vini.%d of %llx\n",i,(long long)vinimask);
|
{
|
||||||
|
if ( SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey) == 0 )
|
||||||
|
fprintf(stderr,"signing error for vini.%d of %llx\n",i,(long long)vinimask);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( NSPV_SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey) == 0 )
|
||||||
|
fprintf(stderr,"NSPV signing error for vini.%d of %llx\n",i,(long long)vinimask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -510,6 +518,10 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t *
|
|||||||
int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs)
|
int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs)
|
||||||
{
|
{
|
||||||
int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector<COutput> vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up;
|
int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector<COutput> vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up;
|
||||||
|
if ( KOMODO_NSPV != 0 )
|
||||||
|
{
|
||||||
|
//return(NSPV_addinputs(struct NSPV_utxoresp *used,CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_utxoresp *ptr,int32_t num));
|
||||||
|
}
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
assert(pwalletMain != NULL);
|
assert(pwalletMain != NULL);
|
||||||
const CKeyStore& keystore = *pwalletMain;
|
const CKeyStore& keystore = *pwalletMain;
|
||||||
@@ -605,6 +617,10 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput
|
|||||||
{
|
{
|
||||||
int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up;
|
int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up;
|
||||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||||
|
if ( KOMODO_NSPV != 0 )
|
||||||
|
{
|
||||||
|
//return(NSPV_addinputs(struct NSPV_utxoresp *used,CMutableTransaction &mtx,int64_t total,int32_t maxinputs,struct NSPV_utxoresp *ptr,int32_t num));
|
||||||
|
}
|
||||||
utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos));
|
utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos));
|
||||||
if ( maxinputs > CC_MAXVINS )
|
if ( maxinputs > CC_MAXVINS )
|
||||||
maxinputs = CC_MAXVINS;
|
maxinputs = CC_MAXVINS;
|
||||||
|
|||||||
@@ -437,9 +437,15 @@ 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 )
|
||||||
|
{
|
||||||
|
memcpy(myprivkey,NSPV_key.vch,32);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if ( Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG) != 0 )
|
if ( Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG) != 0 )
|
||||||
{
|
{
|
||||||
n = (int32_t)strlen(coinaddr);
|
n = (int32_t)strlen(coinaddr);
|
||||||
|
|||||||
@@ -236,6 +236,8 @@ UniValue NSPV_login(char *wifstr)
|
|||||||
result.push_back(Pair("address",NSPV_address));
|
result.push_back(Pair("address",NSPV_address));
|
||||||
result.push_back(Pair("pubkey",HexStr(pubkey)));
|
result.push_back(Pair("pubkey",HexStr(pubkey)));
|
||||||
strcpy(NSPV_pubkeystr,HexStr(pubkey).c_str());
|
strcpy(NSPV_pubkeystr,HexStr(pubkey).c_str());
|
||||||
|
if ( KOMODO_NSPV != 0 )
|
||||||
|
decode_hex(NOTARY_PUBKEY33,33,NSPV_pubkeystr);
|
||||||
result.push_back(Pair("wifprefix",(int64_t)data[0]));
|
result.push_back(Pair("wifprefix",(int64_t)data[0]));
|
||||||
result.push_back(Pair("compressed",(int64_t)(data[len-5] == 1)));
|
result.push_back(Pair("compressed",(int64_t)(data[len-5] == 1)));
|
||||||
memset(data,0,sizeof(data));
|
memset(data,0,sizeof(data));
|
||||||
|
|||||||
Reference in New Issue
Block a user