From 573285dd7e987e42b73208c5d96d18c7c976eca5 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 11 Dec 2014 22:36:59 +1100 Subject: [PATCH] ckdb/php - selectively support multiple payout addresses - still needs pplns changes --- pool/base.php | 14 ++--- pool/page.php | 5 +- pool/page_addrmgt.php | 133 +++++++++++++++++++++++++++++++++++++++++ pool/page_allwork.php | 4 +- pool/page_api.php | 29 ++++----- pool/page_blocks.php | 4 +- pool/page_ckp.php | 4 +- pool/page_help.php | 4 +- pool/page_index.php | 4 +- pool/page_payments.php | 4 +- pool/page_payout.php | 4 +- pool/page_pblocks.php | 4 +- pool/page_pplns.php | 4 +- pool/page_reg.php | 18 +++--- pool/page_reset.php | 4 +- pool/page_settings.php | 62 ++++++++++--------- pool/page_stats.php | 4 +- pool/page_userset.php | 4 +- pool/page_workers.php | 4 +- pool/page_workmgt.php | 4 +- pool/prime.php | 14 +++-- src/ckdb.h | 2 +- src/ckdb_cmd.c | 46 ++++++++------ 23 files changed, 267 insertions(+), 112 deletions(-) create mode 100644 pool/page_addrmgt.php diff --git a/pool/base.php b/pool/base.php index 4f94e55f..1c9824f2 100644 --- a/pool/base.php +++ b/pool/base.php @@ -238,7 +238,7 @@ function dbd($data, $user) # function dbdown() { - gopage(NULL, 'dbd', 'dbd', def_menu(), '', '', true, false, false); + gopage(NULL, NULL, 'dbd', 'dbd', def_menu(), '', '', true, false, false); } # function syse($data, $user) @@ -248,7 +248,7 @@ function syse($data, $user) # function syserror() { - gopage(NULL, 'syse', 'syse', def_menu(), '', '', true, false, false); + gopage(NULL, NULL, 'syse', 'syse', def_menu(), '', '', true, false, false); } # function f404($data) @@ -258,10 +258,10 @@ function f404($data) # function do404() { - gopage(NULL, 'f404', 'f404', def_menu(), '', '', true, false, false); + gopage(NULL, NULL, 'f404', 'f404', def_menu(), '', '', true, false, false); } # -function showPage($page, $menu, $name, $user) +function showPage($info, $page, $menu, $name, $user) { # If you are doing development, use without '@' # Then switch to '@' when finished @@ -270,14 +270,14 @@ function showPage($page, $menu, $name, $user) $fun = 'show_' . $page; if (function_exists($fun)) - $fun($page, $menu, $name, $user); + $fun($info, $page, $menu, $name, $user); else do404(); } # function showIndex() { - showPage('index', def_menu(), '', false); + showPage(NULL, 'index', def_menu(), '', false); } # function offline() @@ -286,7 +286,7 @@ function offline() { $ip = $_SERVER['REMOTE_ADDR']; if ($ip != '192.168.1.666') - gopage(NULL, file_get_contents('./maintenance.txt'), + gopage(NULL, NULL, file_get_contents('./maintenance.txt'), 'offline', NULL, '', '', false, false, false); } } diff --git a/pool/page.php b/pool/page.php index 1b794671..032205f3 100644 --- a/pool/page.php +++ b/pool/page.php @@ -436,7 +436,7 @@ function pgfoot() return $foot; } # -function gopage($data, $pagefun, $page, $menu, $name, $user, $ispage = true, $dotop = true, $douser = true) +function gopage($info, $data, $pagefun, $page, $menu, $name, $user, $ispage = true, $dotop = true, $douser = true) { global $dbg, $stt; global $page_scripts; @@ -449,7 +449,8 @@ function gopage($data, $pagefun, $page, $menu, $name, $user, $ispage = true, $do else $pg = ''; - $info = homeInfo($user); + if ($info === NULL) + $info = homeInfo($user); if ($ispage == true) { diff --git a/pool/page_addrmgt.php b/pool/page_addrmgt.php new file mode 100644 index 00000000..042ad5dc --- /dev/null +++ b/pool/page_addrmgt.php @@ -0,0 +1,133 @@ +Address Management'; + + if ($err != '') + $pg .= "$err

"; + + $pg .= makeForm('addrmgt'); + $pg .= "\n"; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= ''; + + $ans = userSettings($user); + + $offset = 0; + $count = 0; + if ($ans['STATUS'] == 'ok') + { + $count = $ans['rows']; + for ($i = 0; $i < $count; $i++) + { + if ((($offset) % 2) == 0) + $row = 'even'; + else + $row = 'odd'; + + $pg .= " 0 && $count < 1000) + { + $addrarr = array(); + for ($i = 0; $i < $count; $i++) + { + $addr = getparam('addr:'.$i, false); + $ratio = getparam('ratio:'.$i, false); + if (!nuem($addr) && !nuem($ratio)) + $addrarr[] = array('addr' => $addr, 'ratio' => $ratio); + } + $ans = userSettings($user, null, $addrarr, $pass); + if ($ans['STATUS'] != 'ok') + $err = $ans['ERROR']; +#$err = print_r($addrarr, true).$pass; + } + } + + $pg = addrmgtuser($data, $user, $err); + + return $pg; +} +# +function show_addrmgt($info, $page, $menu, $name, $user) +{ + gopage($info, NULL, 'doaddrmgt', $page, $menu, $name, $user); +} +# +?> diff --git a/pool/page_allwork.php b/pool/page_allwork.php index af210dfb..d190f398 100644 --- a/pool/page_allwork.php +++ b/pool/page_allwork.php @@ -39,9 +39,9 @@ function doallwork($data, $user) return $pg; } # -function show_allwork($page, $menu, $name, $user) +function show_allwork($info, $page, $menu, $name, $user) { - gopage(NULL, 'doallwork', $page, $menu, $name, $user); + gopage($info, NULL, 'doallwork', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_api.php b/pool/page_api.php index 8b773410..9819b5b7 100644 --- a/pool/page_api.php +++ b/pool/page_api.php @@ -9,7 +9,7 @@ function no_api($json = "") exit(0); } # -function show_api($page, $menu, $name, $user) +function show_api($info, $page, $menu, $name, $user) { global $fld_sep; $u = getparam('username', true); @@ -29,20 +29,21 @@ function show_api($page, $menu, $name, $user) no_api($jfu); if (nuem($work)) { - $ans = homeInfo($u); - if ($ans === false) + if ($info === NULL) + $info = homeInfo($u); + if ($info === false) no_api($jfu); - $rep = fldEncode($ans, 'lastbc', true); - $rep .= fldEncode($ans, 'lastheight', false); - $rep .= fldEncode($ans, 'currndiff', false); - $rep .= fldEncode($ans, 'lastblock', false); - $rep .= fldEncode($ans, 'lastblockheight', false); - $rep .= fldEncode($ans, 'blockacc', false); - $rep .= fldEncode($ans, 'blockerr', false); - $rep .= fldEncode($ans, 'p_hashrate5m', false); - $rep .= fldEncode($ans, 'p_hashrate1hr', false); - $rep .= fldEncode($ans, 'u_hashrate5m', false); - $rep .= fldEncode($ans, 'u_hashrate1hr', false); + $rep = fldEncode($info, 'lastbc', true); + $rep .= fldEncode($info, 'lastheight', false); + $rep .= fldEncode($info, 'currndiff', false); + $rep .= fldEncode($info, 'lastblock', false); + $rep .= fldEncode($info, 'lastblockheight', false); + $rep .= fldEncode($info, 'blockacc', false); + $rep .= fldEncode($info, 'blockerr', false); + $rep .= fldEncode($info, 'p_hashrate5m', false); + $rep .= fldEncode($info, 'p_hashrate1hr', false); + $rep .= fldEncode($info, 'u_hashrate5m', false); + $rep .= fldEncode($info, 'u_hashrate1hr', false); } else { diff --git a/pool/page_blocks.php b/pool/page_blocks.php index 95aeba1e..1bf6b9f3 100644 --- a/pool/page_blocks.php +++ b/pool/page_blocks.php @@ -182,9 +182,9 @@ function doblocks($data, $user) return $pg; } # -function show_blocks($page, $menu, $name, $user) +function show_blocks($info, $page, $menu, $name, $user) { - gopage(NULL, 'doblocks', $page, $menu, $name, $user); + gopage($info, NULL, 'doblocks', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_ckp.php b/pool/page_ckp.php index dad79f4f..aa59fb97 100644 --- a/pool/page_ckp.php +++ b/pool/page_ckp.php @@ -62,9 +62,9 @@ function dockp($data, $user) return $pg; } # -function show_ckp($page, $menu, $name, $user) +function show_ckp($info, $page, $menu, $name, $user) { - gopage(NULL, 'dockp', $page, $menu, $name, $user); + gopage($info, NULL, 'dockp', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_help.php b/pool/page_help.php index 41546dcf..2ed74e87 100644 --- a/pool/page_help.php +++ b/pool/page_help.php @@ -5,9 +5,9 @@ function dohelp($data, $user) return '

Helpless

Helpless'; } # -function show_help($page, $menu, $name, $user) +function show_help($info, $page, $menu, $name, $user) { - gopage(NULL, 'dohelp', $page, $menu, $name, $user); + gopage($info, NULL, 'dohelp', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_index.php b/pool/page_index.php index d9d423fb..106d0402 100644 --- a/pool/page_index.php +++ b/pool/page_index.php @@ -2,9 +2,9 @@ # @include_once('myindex.php'); # -function show_index($page, $menu, $name, $user) +function show_index($info, $page, $menu, $name, $user) { - gopage(NULL, 'doindex', $page, $menu, $name, $user); + gopage($info, NULL, 'doindex', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_payments.php b/pool/page_payments.php index f3ddc309..db6919d4 100644 --- a/pool/page_payments.php +++ b/pool/page_payments.php @@ -34,9 +34,9 @@ function dopayments($data, $user) return $pg; } # -function show_payments($page, $menu, $name, $user) +function show_payments($info, $page, $menu, $name, $user) { - gopage(NULL, 'dopayments', $page, $menu, $name, $user); + gopage($info, NULL, 'dopayments', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_payout.php b/pool/page_payout.php index af87e2e6..cca9ee40 100644 --- a/pool/page_payout.php +++ b/pool/page_payout.php @@ -13,9 +13,9 @@ function dopayout($data, $user) return $pg; } # -function show_payout($page, $menu, $name, $user) +function show_payout($info, $page, $menu, $name, $user) { - gopage(NULL, 'dopayout', $page, $menu, $name, $user); + gopage($info, NULL, 'dopayout', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_pblocks.php b/pool/page_pblocks.php index 86e9aea7..7bedd01d 100644 --- a/pool/page_pblocks.php +++ b/pool/page_pblocks.php @@ -7,9 +7,9 @@ function dopblocks($data, $user) return doblocks($data, null); } # -function show_pblocks($page, $menu, $name, $user) +function show_pblocks($info, $page, $menu, $name, $user) { - gopage(NULL, 'dopblocks', $page, $menu, $name, $user); + gopage($info, NULL, 'dopblocks', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_pplns.php b/pool/page_pplns.php index 116763aa..4f3daff9 100644 --- a/pool/page_pplns.php +++ b/pool/page_pplns.php @@ -281,9 +281,9 @@ Block: return $pg; } # -function show_pplns($page, $menu, $name, $user) +function show_pplns($info, $page, $menu, $name, $user) { - gopage(NULL, 'dopplns', $page, $menu, $name, $user); + gopage($info, NULL, 'dopplns', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_reg.php b/pool/page_reg.php index d1411742..05021106 100644 --- a/pool/page_reg.php +++ b/pool/page_reg.php @@ -79,7 +79,7 @@ function doreg2($data) return $pg; } # -function try_reg($page, $menu, $name, $u) +function try_reg($info, $page, $menu, $name, $u) { $user = getparam('user', false); $mail = trim(getparam('mail', false)); @@ -128,12 +128,12 @@ function try_reg($page, $menu, $name, $u) { $ans = userReg($user, $mail, $pass); if ($ans['STATUS'] == 'ok') - gopage($data, 'doreg2', $page, $menu, $name, $u, true, true, false); + gopage($info, $data, 'doreg2', $page, $menu, $name, $u, true, true, false); else $data['error'] = "Invalid username, password or email address"; } - gopage($data, 'doregres', $page, $menu, $name, $u, true, true, false); + gopage($info, $data, 'doregres', $page, $menu, $name, $u, true, true, false); } # function doreset2($data) @@ -179,7 +179,7 @@ function doreset2($data) return $pg; } # -function try_reset($page, $menu, $name, $u) +function try_reset($info, $page, $menu, $name, $u) { $user = getparam('user', false); $mail = trim(getparam('mail', false)); @@ -199,20 +199,20 @@ function try_reset($page, $menu, $name, $u) { $data = array('user' => $user, 'email' => $mail); - gopage($data, 'doreset2', $page, $menu, $name, $u, true, true, false); + gopage($info, $data, 'doreset2', $page, $menu, $name, $u, true, true, false); } } - gopage($data, 'doregres', $page, $menu, $name, $u, true, true, false); + gopage($info, $data, 'doregres', $page, $menu, $name, $u, true, true, false); } # -function show_reg($page, $menu, $name, $u) +function show_reg($info, $page, $menu, $name, $u) { $reg = getparam('Register', false); if ($reg !== NULL) - try_reg($page, $menu, $name, $u); + try_reg($info, $page, $menu, $name, $u); else - try_reset($page, $menu, $name, $u); + try_reset($info, $page, $menu, $name, $u); } # ?> diff --git a/pool/page_reset.php b/pool/page_reset.php index 7dc584fe..57be33fc 100644 --- a/pool/page_reset.php +++ b/pool/page_reset.php @@ -158,9 +158,9 @@ function doreset($data, $u) return resetfail(); } # -function show_reset($page, $menu, $name, $u) +function show_reset($info, $page, $menu, $name, $u) { - gopage(array(), 'doreset', $page, $menu, $name, $u, true, true, false); + gopage($info, array(), 'doreset', $page, $menu, $name, $u, true, true, false); } # ?> diff --git a/pool/page_settings.php b/pool/page_settings.php index 5838dfdc..c6d30757 100644 --- a/pool/page_settings.php +++ b/pool/page_settings.php @@ -33,28 +33,31 @@ function settings($data, $user, $email, $addr, $err) $pg .= ''; $pg .= ''; - $pg .= ''; + $pg .= '
AddressRatio%
'; - $pg .= makeForm('settings'); - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= 'To change your payout address, enter a new address and your password'; - $pg .= '
'; - $pg .= 'BTC Address:'; - $pg .= ''; - $pg .= ""; - $pg .= '
'; - $pg .= 'Password:'; - $pg .= ''; - $pg .= ''; - $pg .= '
'; - $pg .= 'Change: '; - $pg .= '
'; + if (!isset($data['info']['u_multiaddr'])) + { + $pg .= makeForm('settings'); + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= ''; + $pg .= '
'; + $pg .= 'To change your payout address, enter a new address and your password'; + $pg .= '
'; + $pg .= 'BTC Address:'; + $pg .= ''; + $pg .= ""; + $pg .= '
'; + $pg .= 'Password:'; + $pg .= ''; + $pg .= ''; + $pg .= '
'; + $pg .= 'Change: '; + $pg .= '
'; - $pg .= '
'; + $pg .= '
'; + } $pg .= makeForm('settings'); $pg .= ''; @@ -101,11 +104,14 @@ function dosettings($data, $user) $check = true; break; case 'Address': - $addr = getparam('baddr', false); - $addrarr = array(array('addr' => $addr)); - $pass = getparam('pass', false); - $ans = userSettings($user, null, $addrarr, $pass); - $check = true; + if (!isset($data['info']['u_multiaddr'])) + { + $addr = getparam('baddr', false); + $addrarr = array(array('addr' => $addr)); + $pass = getparam('pass', false); + $ans = userSettings($user, null, $addrarr, $pass); + $check = true; + } break; case 'Password': $oldpass = getparam('oldpass', false); @@ -149,9 +155,9 @@ function dosettings($data, $user) return $pg; } # -function show_settings($page, $menu, $name, $user) +function show_settings($info, $page, $menu, $name, $user) { - gopage(NULL, 'dosettings', $page, $menu, $name, $user); + gopage($info, NULL, 'dosettings', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_stats.php b/pool/page_stats.php index 203de795..90768813 100644 --- a/pool/page_stats.php +++ b/pool/page_stats.php @@ -99,9 +99,9 @@ function dostats($data, $user) return $pg; } # -function show_stats($page, $menu, $name, $user) +function show_stats($info, $page, $menu, $name, $user) { - gopage(NULL, 'dostats', $page, $menu, $name, $user); + gopage($info, NULL, 'dostats', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_userset.php b/pool/page_userset.php index 9764fa5f..ae4b382c 100644 --- a/pool/page_userset.php +++ b/pool/page_userset.php @@ -92,9 +92,9 @@ function douserset($data, $user) return $pg; } # -function show_userset($page, $menu, $name, $user) +function show_userset($info, $page, $menu, $name, $user) { - gopage(NULL, 'douserset', $page, $menu, $name, $user); + gopage($info, NULL, 'douserset', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_workers.php b/pool/page_workers.php index 938aee9a..dcbfa46c 100644 --- a/pool/page_workers.php +++ b/pool/page_workers.php @@ -188,9 +188,9 @@ function doworkers($data, $user) return $pg; } # -function show_workers($page, $menu, $name, $user) +function show_workers($info, $page, $menu, $name, $user) { - gopage(NULL, 'doworkers', $page, $menu, $name, $user); + gopage($info, NULL, 'doworkers', $page, $menu, $name, $user); } # ?> diff --git a/pool/page_workmgt.php b/pool/page_workmgt.php index 4cea1569..e7ad249a 100644 --- a/pool/page_workmgt.php +++ b/pool/page_workmgt.php @@ -86,9 +86,9 @@ function doworkmgt($data, $user) return $pg; } # -function show_workmgt($page, $menu, $name, $user) +function show_workmgt($info, $page, $menu, $name, $user) { - gopage(NULL, 'doworkmgt', $page, $menu, $name, $user); + gopage($info, NULL, 'doworkmgt', $page, $menu, $name, $user); } # ?> diff --git a/pool/prime.php b/pool/prime.php index c50c69f7..af2bf796 100644 --- a/pool/prime.php +++ b/pool/prime.php @@ -8,6 +8,12 @@ include_once('base.php'); # function process($p, $user, $menu) { + $info = homeInfo($user); + if (is_array($info) && isset($info['u_multiaddr'])) + { + if (isset($menu['Account'])) + $menu['Account']['Addresses'] = 'addrmgt'; + } if ($user == 'Kano' || $user == 'ckolivas' || $user == 'wvr2' || $user == 'aphorise') { $menu['Admin']['ckp'] = 'ckp'; @@ -26,9 +32,9 @@ function process($p, $user, $menu) } if ($page === '') - showPage('index', $menu, '', $user); + showPage($info, 'index', $menu, '', $user); else - showPage($page, $menu, $n, $user); + showPage($info, $page, $menu, $n, $user); } # function def_menu() @@ -80,11 +86,11 @@ function check() { $p = getparam('k', true); if ($p == 'reset') - showPage('reset', $dmenu, '', $who); + showPage(NULL, 'reset', $dmenu, '', $who); else { if (requestRegister() == true) - showPage('reg', $dmenu, '', $who); + showPage(NULL, 'reg', $dmenu, '', $who); else { $p = getparam('k', true); diff --git a/src/ckdb.h b/src/ckdb.h index f656b522..3f28e06d 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.6" -#define CKDB_VERSION DB_VERSION"-0.741" +#define CKDB_VERSION DB_VERSION"-0.742" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index 4b591683..9d1b1ee4 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -163,11 +163,11 @@ static char *cmd_userset(PGconn *conn, char *cmd, char *id, { K_ITEM *i_username, *i_passwordhash, *i_rows, *i_address, *i_ratio; K_ITEM *i_email, *u_item, *pa_item; - char *email; + char *email, *address; char reply[1024] = ""; size_t siz = sizeof(reply); char tmp[1024]; - PAYMENTADDRESSES *paymentaddresses; + PAYMENTADDRESSES *row; K_STORE *pa_store = NULL; K_TREE_CTX ctx[1]; USERS *users; @@ -212,26 +212,24 @@ static char *cmd_userset(PGconn *conn, char *cmd, char *id, K_RLOCK(paymentaddresses_free); pa_item = find_paymentaddresses(users->userid, ctx); + rows = 0; if (pa_item) { - DATA_PAYMENTADDRESSES(paymentaddresses, pa_item); - while (pa_item && CURRENT(&(paymentaddresses->expirydate)) && - paymentaddresses->userid == users->userid) { + DATA_PAYMENTADDRESSES(row, pa_item); + while (pa_item && CURRENT(&(row->expirydate)) && + row->userid == users->userid) { snprintf(tmp, sizeof(tmp), "addr:%d=%s%c", - rows, paymentaddresses->payaddress, FLDSEP); + rows, row->payaddress, FLDSEP); APPEND_REALLOC(answer, off, len, tmp); snprintf(tmp, sizeof(tmp), "ratio:%d=%d%c", - rows, paymentaddresses->payratio, FLDSEP); + rows, row->payratio, FLDSEP); APPEND_REALLOC(answer, off, len, tmp); rows++; pa_item = prev_in_ktree(ctx); - DATA_PAYMENTADDRESSES_NULL(paymentaddresses, pa_item); + DATA_PAYMENTADDRESSES_NULL(row, pa_item); } - K_RUNLOCK(paymentaddresses_free); - } else { - K_RUNLOCK(paymentaddresses_free); - rows = 0; } + K_RUNLOCK(paymentaddresses_free); snprintf(tmp, sizeof(tmp), "rows=%d%cflds=%s%c", rows, FLDSEP, @@ -306,12 +304,22 @@ static char *cmd_userset(PGconn *conn, char *cmd, char *id, reason = "Invalid address"; goto struckout; } + address = transfer_data(i_address); + pa_item = pa_store->head; + while (pa_item) { + DATA_PAYMENTADDRESSES(row, pa_item); + if (strcmp(row->payaddress, address) == 0) { + K_WUNLOCK(paymentaddresses_free); + reason = "Duplicate address"; + goto struckout; + } + pa_item = pa_item->next; + } pa_item = k_unlink_head(paymentaddresses_free); - DATA_PAYMENTADDRESSES(paymentaddresses, pa_item); - bzero(paymentaddresses, sizeof(*paymentaddresses)); - STRNCPY(paymentaddresses->payaddress, - transfer_data(i_address)); - paymentaddresses->payratio = ratio; + DATA_PAYMENTADDRESSES(row, pa_item); + bzero(row, sizeof(*row)); + STRNCPY(row->payaddress, address); + row->payratio = ratio; k_add_head(pa_store, pa_item); } K_WUNLOCK(paymentaddresses_free); @@ -328,8 +336,8 @@ static char *cmd_userset(PGconn *conn, char *cmd, char *id, if (pa_store && pa_store->count > 0) { pa_item = pa_store->head; while (pa_item) { - DATA_PAYMENTADDRESSES(paymentaddresses, pa_item); - if (!btc_valid_address(paymentaddresses->payaddress)) { + DATA_PAYMENTADDRESSES(row, pa_item); + if (!btc_valid_address(row->payaddress)) { reason = "Invalid BTC address"; goto struckout; }