Merge branch 'dev' of https://github.com/blackjok3rtt/komodo into dev
z
This commit is contained in:
@@ -24,7 +24,7 @@ so you can pay to a pubkey, or to its hash. or to a script's hash. the last is h
|
||||
all of the above are the standard bitcoin vout types and there should be plenty of materials about it
|
||||
Encrypted by a verified device
|
||||
what I did with the CC contracts is created a fourth type of vout, the CC vout. this is using the cryptoconditions standard and it is even a different signature mechanism. ed25519 instead of secp256k1. it is basically a big extension to the bitcoin script. There is a special opcode that is added that says it is a CC script.
|
||||
|
||||
|
||||
but it gets more interesting
|
||||
each CC script has an evalcode
|
||||
this is just an arbitrary number. but what it does is allows to create a self-contained universe of CC utxo that all have the same evalcode and that is how a faucet CC differentiates itself from a dice CC, the eval code is different
|
||||
@@ -73,7 +73,7 @@ struct CC_utxo
|
||||
|
||||
// these are the parameters stored after Verus crypto-condition vouts. new versions may change
|
||||
// the format
|
||||
struct CC_meta
|
||||
struct CC_meta
|
||||
{
|
||||
std::vector<unsigned char> version;
|
||||
uint8_t evalCode;
|
||||
@@ -110,7 +110,7 @@ int32_t komodo_nextheight();
|
||||
static const uint256 zeroid;
|
||||
bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock);
|
||||
int32_t is_hexstr(char *str,int32_t n);
|
||||
bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL);
|
||||
bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL, bool fSkipExpiry = false);
|
||||
//uint64_t myGettxout(uint256 hash,int32_t n);
|
||||
bool myIsutxo_spentinmempool(uint256 txid,int32_t vout);
|
||||
bool mytxid_inmempool(uint256 txid);
|
||||
|
||||
11
src/cc/dapps/Makefile
Normal file
11
src/cc/dapps/Makefile
Normal file
@@ -0,0 +1,11 @@
|
||||
# just type make to compile all dapps
|
||||
all: zmigrate oraclefeed
|
||||
|
||||
zmigrate:
|
||||
$(CC) zmigrate.c -o zmigrate -lm
|
||||
|
||||
oraclefeed:
|
||||
$(CC) oraclefeed.c -o oraclefeed -lm
|
||||
|
||||
clean:
|
||||
rm zmigrate oraclefeed
|
||||
28
src/cc/dapps/README.md
Normal file
28
src/cc/dapps/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# CryptoCondition dApps
|
||||
|
||||
## Compiling
|
||||
|
||||
To compile all dapps in this directory:
|
||||
|
||||
make
|
||||
|
||||
## zmigrate - Sprout to Sapling Migration dApp
|
||||
|
||||
This tool converts Sprout zaddress funds into Sapling funds in a new Sapling address.
|
||||
|
||||
### Usage
|
||||
|
||||
./zmigrate COIN zsaplingaddr
|
||||
|
||||
The above command may need to be run multiple times to complete the process.
|
||||
|
||||
This CLI implementation will be called by GUI wallets, average users do not
|
||||
need to worry about using this low-level tool.
|
||||
|
||||
## oraclefeed - feed of price data using oracles
|
||||
|
||||
### Usage
|
||||
|
||||
./oraclefeed $ACNAME $ORACLETXID $MYPUBKEY $FORMAT $BINDTXID [refcoin_cli]
|
||||
|
||||
Supported formats are L and Ihh. Price data from CoinDesk API.
|
||||
@@ -670,6 +670,7 @@ int64_t find_onetime_amount(char *coinstr,char *coinaddr)
|
||||
coinaddr[0] = 0;
|
||||
if ( (array= get_listunspent(coinstr,"")) != 0 )
|
||||
{
|
||||
//printf("got listunspent.(%s)\n",jprint(array,0));
|
||||
if ( (n= cJSON_GetArraySize(array)) > 0 )
|
||||
{
|
||||
for (i=0; i<n; i++)
|
||||
@@ -734,6 +735,7 @@ int32_t z_sendmany(char *opidstr,char *coinstr,char *acname,char *srcaddr,char *
|
||||
cJSON *retjson; char *retstr,params[1024],addr[128];
|
||||
sprintf(params,"'[{\"address\":\"%s\",\"amount\":%.8f}]'",destaddr,dstr(amount));
|
||||
sprintf(addr,"\"%s\"",srcaddr);
|
||||
printf("z_sendmany from.(%s) -> %s\n",srcaddr,params);
|
||||
if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_sendmany",addr,params,"","")) != 0 )
|
||||
{
|
||||
printf("unexpected json z_sendmany.(%s)\n",jprint(retjson,0));
|
||||
@@ -906,7 +908,7 @@ int32_t main(int32_t argc,char **argv)
|
||||
zsaddr = clonestr(argv[2]);
|
||||
printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr);
|
||||
uint32_t lastopid; char coinaddr[64],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee;
|
||||
stdamount = 10000 * SATOSHIDEN;
|
||||
//stdamount = 500 * SATOSHIDEN;
|
||||
txfee = 10000;
|
||||
again:
|
||||
printf("start processing zmigrate\n");
|
||||
@@ -916,7 +918,7 @@ again:
|
||||
{
|
||||
if ( have_pending_opid(coinstr,0) != 0 )
|
||||
{
|
||||
sleep(60);
|
||||
sleep(10);
|
||||
continue;
|
||||
}
|
||||
if ( (amount= find_onetime_amount(coinstr,coinaddr)) > txfee )
|
||||
@@ -930,14 +932,33 @@ again:
|
||||
if ( (amount= find_sprout_amount(coinstr,zcaddr)) > txfee )
|
||||
{
|
||||
// generate taddr, send max of 10000.0001
|
||||
if ( amount > stdamount+txfee )
|
||||
amount = stdamount + txfee;
|
||||
static int64_t lastamount,lastamount2,lastamount3,lastamount4,refamount = 5000 * SATOSHIDEN;
|
||||
stdamount = refamount;
|
||||
if ( amount == lastamount && amount == lastamount2 )
|
||||
{
|
||||
stdamount /= 10;
|
||||
if ( amount == lastamount3 && amount == lastamount4 )
|
||||
stdamount /= 10;
|
||||
}
|
||||
if ( stdamount < SATOSHIDEN )
|
||||
{
|
||||
stdamount = SATOSHIDEN;
|
||||
refamount = SATOSHIDEN * 50;
|
||||
}
|
||||
if ( stdamount < refamount )
|
||||
refamount = stdamount;
|
||||
lastamount4 = lastamount3;
|
||||
lastamount3 = lastamount2;
|
||||
lastamount2 = lastamount;
|
||||
lastamount = amount;
|
||||
if ( amount > stdamount+2*txfee )
|
||||
amount = stdamount + 2*txfee;
|
||||
if ( getnewaddress(coinaddr,coinstr,"") == 0 )
|
||||
{
|
||||
z_sendmany(opidstr,coinstr,"",zcaddr,coinaddr,amount-txfee);
|
||||
lastopid = (uint32_t)time(NULL);
|
||||
} else printf("couldnt getnewaddress!\n");
|
||||
sleep(30);
|
||||
sleep(3);
|
||||
continue;
|
||||
}
|
||||
if ( time(NULL) > lastopid+600 )
|
||||
|
||||
@@ -427,11 +427,11 @@ void *dicefinish(void *_ptr)
|
||||
if ( vin0_needed > 0 )
|
||||
{
|
||||
num = 0;
|
||||
//fprintf(stderr,"iter.%d vin0_needed.%d\n",iter,vin0_needed);
|
||||
//fprintf(stderr,"iter.%d vin0_needed.%d\n",iter,vin0_needed);
|
||||
utxos = (struct dicefinish_utxo *)calloc(vin0_needed,sizeof(*utxos));
|
||||
if ( (n= dicefinish_utxosget(num,utxos,vin0_needed,coinaddr)) > 0 )
|
||||
{
|
||||
//fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num);
|
||||
//fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num);
|
||||
m = 0;
|
||||
DL_FOREACH_SAFE(DICEFINISH_LIST,ptr,tmp)
|
||||
{
|
||||
@@ -484,7 +484,8 @@ void *dicefinish(void *_ptr)
|
||||
//fprintf(stderr,"error ready.%d dicefinish %d of %d process %s %s using need %.8f finish.%s size.%d betspent.%d\n",ptr->bettxid_ready,m,n,iter<0?"loss":"win",ptr->bettxid.GetHex().c_str(),(double)(iter<0 ? 0 : ptr->winamount)/COIN,ptr->txid.GetHex().c_str(),(int32_t)ptr->rawtx.size(),dice_betspent((char *)"dicefinish",ptr->bettxid));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ( system("cc/dapps/sendmany100") != 0 )
|
||||
fprintf(stderr,"error issing cc/dapps/sendmany100\n");
|
||||
free(utxos);
|
||||
}
|
||||
}
|
||||
@@ -533,7 +534,7 @@ void DiceQueue(int32_t iswin,uint64_t sbits,uint256 fundingtxid,uint256 bettxid,
|
||||
else
|
||||
{
|
||||
//fprintf(stderr,"DiceQueue status bettxid.%s already in list\n",bettxid.GetHex().c_str());
|
||||
_dicehash_clear(bettxid);
|
||||
//_dicehash_clear(bettxid);
|
||||
}
|
||||
pthread_mutex_unlock(&DICE_MUTEX);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user