diff --git a/src/generator.c b/src/generator.c index 96eac99e..f4f5da80 100644 --- a/src/generator.c +++ b/src/generator.c @@ -311,6 +311,11 @@ retry: LOGNOTICE("Submitting block data!"); if (submit_block(cs, buf + 12)) send_proc(ckp->stratifier, "block"); + } else if (cmdmatch(buf, "checkaddr:")) { + if (validate_address(cs, buf + 10)) + send_unix_msg(sockd, "true"); + else + send_unix_msg(sockd, "false"); } else if (cmdmatch(buf, "loglevel")) { sscanf(buf, "loglevel=%d", &ckp->loglevel); } else if (cmdmatch(buf, "ping")) { diff --git a/src/stratifier.c b/src/stratifier.c index 387d3a19..1125a212 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -2548,11 +2548,33 @@ int stratifier(proc_instance_t *pi) { pthread_t pth_blockupdate, pth_statsupdate; ckpool_t *ckp = pi->ckp; - char *buf; - int ret; + char *buf, *msg; + int ret = 1; LOGWARNING("%s stratifier starting", ckp->name); + /* Wait for the generator to have something for us */ + do { + if (!ping_main(ckp)) { + ret = 1; + goto out; + } + buf = send_recv_proc(ckp->generator, "ping"); + } while (!buf); + + ASPRINTF(&msg, "checkaddr:%s", ckp->btcaddress); + buf = send_recv_proc(ckp->generator, msg); + dealloc(msg); + if (!buf) { + LOGEMERG("Fatal: No response to checkaddr from generator"); + goto out; + } + if (cmdmatch(buf, "false")) { + LOGEMERG("Fatal: btcaddress invalid accoring to bitcoind"); + dealloc(buf); + goto out; + } + /* Store this for use elsewhere */ hex2bin(scriptsig_header_bin, scriptsig_header, 41); address_to_pubkeytxn(pubkeytxnbin, ckp->btcaddress); @@ -2562,14 +2584,6 @@ int stratifier(proc_instance_t *pi) * id on restarts */ blockchange_id = workbase_id = ((int64_t)time(NULL)) << 32; - /* Wait for the generator to have something for us */ - do { - if (!ping_main(ckp)) { - ret = 1; - goto out; - } - buf = send_recv_proc(ckp->generator, "ping"); - } while (!buf); dealloc(buf); if (!ckp->serverurl)