Browse Source

Implement --coinbase-addr for solo mining

Luke Dashjr 13 years ago
parent
commit
e333074552
3 changed files with 38 additions and 1 deletions
  1. 1 0
      README
  2. 1 1
      libblkmaker
  3. 36 0
      miner.c

+ 1 - 0
README

@@ -134,6 +134,7 @@ Options for both config file and command line:
 --api-port          Port number of miner API (default: 4028)
 --balance           Change multipool strategy from failover to even share balance
 --benchmark         Run BFGMiner in benchmark mode - produces no shares
+--coinbase-addr <arg> Set coinbase payout address for solo mining
 --coinbase-sig <arg> Set coinbase signature when possible
 --debug|-D          Enable debug output
 --debuglog          Enable debug logging

+ 1 - 1
libblkmaker

@@ -1 +1 @@
-Subproject commit a9a29294b2028dfd68fba35d42d440d3283f668d
+Subproject commit fde65d1bc043a13292986c2cab9c3cd01e50735e

+ 36 - 0
miner.c

@@ -100,6 +100,13 @@ bool opt_protocol;
 static bool opt_benchmark;
 static bool want_longpoll = true;
 static bool want_gbt = true;
+#if BLKMAKER_VERSION > 1 || 1 /* TEMPORARY */
+struct _cbscript_t {
+	char *data;
+	size_t sz;
+};
+static struct _cbscript_t opt_coinbase_script;
+#endif
 #if BLKMAKER_VERSION < 1
 const
 #endif
@@ -521,6 +528,23 @@ char *set_strdup(const char *arg, char **p)
 	return NULL;
 }
 
+#if BLKMAKER_VERSION > 1 || 1 /* TEMPORARY */
+static char *set_b58addr(const char *arg, struct _cbscript_t *p)
+{
+	size_t scriptsz = blkmk_address_to_script(NULL, 0, arg);
+	if (!scriptsz)
+		return "Invalid address";
+	char *script = malloc(scriptsz);
+	if (blkmk_address_to_script(script, scriptsz, arg) != scriptsz) {
+		free(script);
+		return "Failed to convert address to script";
+	}
+	p->data = script;
+	p->sz = scriptsz;
+	return NULL;
+}
+#endif
+
 #ifdef HAVE_LIBUDEV
 #include <libudev.h>
 #endif
@@ -994,6 +1018,14 @@ static struct opt_table opt_config_table[] = {
 		     set_int_0_to_9999, opt_show_intval, &opt_bench_algo,
 		     opt_hidden),
 #endif
+#if BLKMAKER_VERSION > 1 || 1 /* TEMPORARY */
+	OPT_WITH_ARG("--coinbase-addr",
+		     set_b58addr, NULL, &opt_coinbase_script,
+		     "Set coinbase payout address for solo mining"),
+	OPT_WITH_ARG("--coinbase-payout|--cbaddr|--cb-addr|--payout",
+		     set_b58addr, NULL, &opt_coinbase_script,
+		     opt_hidden),
+#endif
 #if BLKMAKER_VERSION > 0
 	OPT_WITH_ARG("--coinbase-sig",
 		     set_strdup, NULL, &opt_coinbase_sig,
@@ -1544,6 +1576,10 @@ static bool work_decode(const json_t *val, struct work *work)
 			goto err_out;
 		}
 		work->rolltime = blkmk_time_left(work->tmpl, time(NULL));
+#if BLKMAKER_VERSION > 1 || 1 /* TEMPORARY */
+		if (opt_coinbase_script.sz)
+			blkmk_init_generation(work->tmpl, opt_coinbase_script.data, opt_coinbase_script.sz);
+#endif
 #if BLKMAKER_VERSION > 0
 		{
 			ssize_t ae = blkmk_append_coinbase_safe(work->tmpl, opt_coinbase_sig, 101);