Skip to content

Commit

Permalink
Provide a --btc-sig option to optionally add a custom signature to th…
Browse files Browse the repository at this point in the history
…e solo mining coinbsae
  • Loading branch information
ckolivas committed Apr 2, 2014
1 parent c481f2c commit 51b2259
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
25 changes: 20 additions & 5 deletions cgminer.c
Expand Up @@ -127,6 +127,7 @@ enum benchwork {
BENCHWORK_COUNT
};
static char *opt_btc_address;
static char *opt_btc_sig;
static char *opt_benchfile;
static bool opt_benchfile_display;
static FILE *benchfile_in;
Expand Down Expand Up @@ -1333,9 +1334,14 @@ static struct opt_table opt_config_table[] = {
set_int_0_to_100, opt_show_intval, &opt_bxm_bits,
"Set BXM bits for overclocking"),
#endif
#ifdef HAVE_LIBCURL
OPT_WITH_ARG("--btc-address",
opt_set_charp, NULL, &opt_btc_address,
"Set bitcoin target address when solo mining to bitcoind"),
"Set bitcoin target address when solo mining to bitcoind (mandatory)"),
OPT_WITH_ARG("--btc-sig",
opt_set_charp, NULL, &opt_btc_sig,
"Set signature to add to coinbase when solo mining (optional)"),
#endif
#ifdef HAVE_CURSES
OPT_WITHOUT_ARG("--compact",
opt_set_bool, &opt_compact,
Expand Down Expand Up @@ -2355,6 +2361,15 @@ static bool gbt_solo_decode(struct pool *pool, json_t *res_val)
pool->nonce2_offset = 41 + ofs;
ofs += 8;

if (opt_btc_sig) {
len = strlen(opt_btc_sig);
if (len > 32)
len = 32;
pool->scriptsig_base[ofs++] = len;
memcpy(pool->scriptsig_base + ofs, opt_btc_sig, len);
ofs += len;
}

pool->scriptsig_base[0] = ofs++; // Template length
pool->n1_len = ofs;

Expand Down Expand Up @@ -3143,7 +3158,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)

/* build JSON-RPC request */
if (work->gbt) {
char gbt_block[512], varint[12];
char gbt_block[1024], varint[12];
unsigned char data[80];

flip80(data, work->data);
Expand All @@ -3165,12 +3180,12 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
__bin2hex(varint, (const unsigned char *)&val32, 4);
}
strcat(gbt_block, varint); // +8 max
strcat(gbt_block, work->coinbase); // + 268 max
strcat(gbt_block, work->coinbase);

s = malloc(512);
s = malloc(1024);
if (unlikely(!s))
quit(1, "Failed to malloc s in submit_upstream_work");
sprintf(s, "{\"id\": 0, \"method\": \"submitblock\", \"params\": [\"%s", gbt_block); // 46 + 438
sprintf(s, "{\"id\": 0, \"method\": \"submitblock\", \"params\": [\"%s", gbt_block);
/* Has submit/coinbase support */
if (!pool->has_gbt) {
cg_rlock(&pool->gbt_lock);
Expand Down
2 changes: 1 addition & 1 deletion miner.h
Expand Up @@ -1266,7 +1266,7 @@ struct pool {
unsigned char merklebin[16 * 32];
int transactions;
char *txn_data;
unsigned char scriptsig_base[42 + 2];
unsigned char scriptsig_base[100];
unsigned char script_pubkey[25 + 3];
int nValue;
CURL *gbt_curl;
Expand Down

0 comments on commit 51b2259

Please sign in to comment.