diff --git a/README b/README index 89c34734..209b910f 100644 --- a/README +++ b/README @@ -224,6 +224,10 @@ new network blocks and is 100 by default. It is intended to be a backup only for when the notifier is not set up and only polls if the "notify" field is not set on a btcd. +"donation" : Optional percentage donation of block reward that goes to the +developer of ckpool to assist in further development and maintenance of the +code. Takes a floating point value and defaults to zero if not set. + "nodeserver" : This takes the same format as the serverurl array and specifies additional IPs/ports to bind to that will accept incoming requests for mining node communications. It is recommended to selectively isolate this address diff --git a/ckpool.conf b/ckpool.conf index 01ac61d8..e90794f5 100644 --- a/ckpool.conf +++ b/ckpool.conf @@ -19,6 +19,7 @@ "btcaddress" : "14BMjogz69qe8hk9thyzbmR5pg34mVKB1e", "btcsig" : "/mined by ck/", "blockpoll" : 100, +"donation" : 2.0, "nonce1length" : 4, "nonce2length" : 8, "update_interval" : 30, diff --git a/src/ckpool.c b/src/ckpool.c index 361efe85..32e259bb 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -1461,6 +1461,12 @@ static void parse_config(ckpool_t *ckp) json_get_int64(&ckp->maxdiff, json_conf, "maxdiff"); json_get_string(&ckp->logdir, json_conf, "logdir"); json_get_int(&ckp->maxclients, json_conf, "maxclients"); + json_get_double(&ckp->donation, json_conf, "donation"); + /* Avoid dust-sized donations */ + if (ckp->donation < 0.1) + ckp->donation = 0; + else if (ckp->donation > 99.9) + ckp->donation = 99.9; arr_val = json_object_get(json_conf, "proxy"); if (arr_val && json_is_array(arr_val)) { arr_size = json_array_size(arr_val); diff --git a/src/ckpool.h b/src/ckpool.h index 3268bbd6..62d1cab5 100644 --- a/src/ckpool.h +++ b/src/ckpool.h @@ -246,13 +246,16 @@ struct ckpool_instance { bool script; // Address is a script address bool segwit; // Address is a segwit address char *btcsig; // Optional signature to add to coinbase + bool coinbase_valid; // Coinbase transaction confirmed valid + + /* Donation data */ char *donaddress; // Donation address char *tndonaddress; // Testnet donation address char *rtdonaddress; // Regtest donation address bool donscript; // Donation is a script bool donsegwit; // Donation is segwit bool donvalid; // Donation address works on this network - bool coinbase_valid; // Coinbase transaction confirmed valid + double donation; // Percentage donation to development /* Stratum options */ server_instance_t **servers; diff --git a/src/stratifier.c b/src/stratifier.c index 14afdb12..d08cae16 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -598,8 +598,10 @@ static void generate_coinbase(ckpool_t *ckp, workbase_t *wb) // Generation value g64 = wb->coinbasevalue; - if (ckp->donvalid) { - d64 = g64 / 50; // 2% donation + if (ckp->donvalid && ckp->donation > 0) { + double dbl64 = (double)g64 / 100 * ckp->donation; + + d64 = dbl64; g64 -= d64; // To guarantee integers add up to the original coinbasevalue wb->coinb2bin[wb->coinb2len++] = 2 + wb->insert_witness; } else