test
This commit is contained in:
@@ -86,7 +86,7 @@ uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen)
|
||||
void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
|
||||
{
|
||||
static uint256 zeroes;
|
||||
uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,transferflag,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,valuebuf[IGUANA_MAXSCRIPTSIZE]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee;
|
||||
uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,valuebuf[IGUANA_MAXSCRIPTSIZE]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee;
|
||||
iguana_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen);
|
||||
iguana_rwnum(0,&opretbuf[3],sizeof(valuesize),&valuesize);
|
||||
iguana_rwnum(0,&opretbuf[5],sizeof(height),&height);
|
||||
@@ -125,7 +125,6 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
|
||||
}
|
||||
portable_mutex_lock(&KOMODO_KV_mutex);
|
||||
HASH_FIND(hh,KOMODO_KV,key,keylen,ptr);
|
||||
transferflag = 0;
|
||||
if ( ptr != 0 )
|
||||
{
|
||||
if ( (ptr->flags & KOMODO_KVPROTECTED) != 0 && memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
|
||||
@@ -134,7 +133,8 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
|
||||
transferpubstr = (char *)&valueptr[strlen(tstr)];
|
||||
if ( strncmp(tstr,(char *)valueptr,strlen(tstr)) == 0 && is_hexstr(transferpubstr,0) == 64 )
|
||||
{
|
||||
transferflag = 1;
|
||||
memcpy(&ptr->pubkey,&pubkey,sizeof(ptr->pubkey));
|
||||
ptr->height = height;
|
||||
printf("transfer.(%s) to [%s]\n",key,transferpubstr);
|
||||
for (i=0; i<32; i++)
|
||||
((uint8_t *)&pubkey)[31-i] = _decode_hex(&transferpubstr[i*2]);
|
||||
@@ -144,19 +144,13 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
|
||||
else if ( ptr == 0 )
|
||||
{
|
||||
ptr = (struct komodo_kv *)calloc(1,sizeof(*ptr));
|
||||
memcpy(&ptr->pubkey,&pubkey,sizeof(ptr->pubkey));
|
||||
ptr->key = (uint8_t *)calloc(1,keylen);
|
||||
ptr->keylen = keylen;
|
||||
memcpy(ptr->key,key,keylen);
|
||||
newflag = 1;
|
||||
HASH_ADD_KEYPTR(hh,KOMODO_KV,ptr->key,ptr->keylen,ptr);
|
||||
}
|
||||
if ( transferflag != 0 )
|
||||
{
|
||||
memcpy(&ptr->pubkey,&pubkey,sizeof(ptr->pubkey));
|
||||
ptr->height = height;
|
||||
}
|
||||
else if ( newflag != 0 || (ptr->flags & KOMODO_KVPROTECTED) == 0 )
|
||||
if ( newflag != 0 || (ptr->flags & KOMODO_KVPROTECTED) == 0 )
|
||||
{
|
||||
if ( ptr->value != 0 )
|
||||
free(ptr->value), ptr->value = 0;
|
||||
|
||||
@@ -544,10 +544,13 @@ Value kvupdate(const Array& params, bool fHelp)
|
||||
ret.push_back(Pair("error",(char *)"cant modify write once key without passphrase"));
|
||||
return ret;
|
||||
}
|
||||
printf("calc sig for keylen.%d + valuesize.%d\n",keylen,valuesize);
|
||||
sig = komodo_kvsig(keyvalue,keylen+valuesize,privkey);
|
||||
sig = komodo_kvsig(keyvalue,keylen+refvaluesize,privkey);
|
||||
for (i=0; i<32; i++)
|
||||
printf("%02x",((uint8_t *)&sig)[i]);
|
||||
printf(" sig for keylen.%d + valuesize.%d\n",keylen,refvaluesize);
|
||||
}
|
||||
}
|
||||
printf("refvaluesize.%d tmpflags.%d\n",refvaluesize,tmpflags);
|
||||
ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL)));
|
||||
height = chainActive.Tip()->nHeight;
|
||||
if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
|
||||
|
||||
Reference in New Issue
Block a user