99999999) $b4 = ''; else if ($num > 9999999) $b4 = ''; if ($b4 != '') $af = ''; return $b4.$fmt.$af; } # # ... Of course ... check the output and add the txin ... etc. function calctx($ans, $count, $miner_sat, $diffacc_total) { $pg = '
'; $pg .= '
'; $dust = getparam('dust', true); if (nuem($dust) || $dust <= 0) $dust = 10000; $fee = getparam('fee', true); if (nuem($fee) || $fee < 0) $fee = 0; $fee *= 100000000; $adr = array(); $ers = ''; $unpaid = 0; $change = $miner_sat; $dust_amt = 0; # not included in $change for ($i = 0; $i < $count; $i++) { $username = $ans['user:'.$i]; $diffacc_user = $ans['diffacc_user:'.$i]; $pay_sat = floor($miner_sat * $diffacc_user / $diffacc_total); $payaddress = $ans['payaddress:'.$i]; if ($payaddress == 'none') { $len = strlen($username); $c0 = substr($username, 0, 1); if (($c0 == '1' || $c0 == '3') && $len > 26 && $len < 37) $payaddress = $username; else { if ($pay_sat > 0) { $dd = ''; if ($pay_sat < $dust) $dd = ' (dust)'; $ers .= "No address for '$username'$dd
"; } $unpaid += $pay_sat; continue; } } if (isset($adr[$payaddress])) $adr[$payaddress] += $pay_sat; else $adr[$payaddress] = $pay_sat; $change -= $pay_sat; } $txout = ''; $comma = ''; foreach ($adr as $payaddress => $pay_sat) { if ($pay_sat < $dust) $dust_amt += $pay_sat; else { $txout .= "$comma\"$payaddress\":".btcfmt($pay_sat); $comma = ', '; } } if ($change > 0 || $dust_amt > 0 || $change < $fee) { $pg .= "Dust limit = $dust = ".btcfmt($dust); $pg .= ", Dust amount = $dust_amt = ".btcfmt($dust_amt); $pg .= ",
Upaid = $unpaid = ".btcfmt($unpaid); $pg .= ", Change = $change = ".btcfmt($change); $pg .= ",
Fee = $fee = ".btcfmt($fee)."

"; if ($change < $fee) $ers .= "Change ($change) is less than Fee ($fee)
"; if (($dust_amt + $change - $fee) > 0) { $txout .= "$comma\"<changeaddress>\":"; $txout .= btcfmt($dust_amt + $change - $fee); $comma = ', '; } } if (strlen($ers) > 0) $pg .= "$ers
"; $txn = '[{"txid":"<txid1>","vout":<n>},'; $txn .= '{"txid":"<txid2>","vout":<n>}] '; $txn .= '{'.$txout.'}
'; $pg .= $txn.'
'; return $pg; } # function dopplns($data, $user) { global $send_sep; $pg = '

CKPool

'; $blk = getparam('blk', true); if (nuem($blk)) { $tx = ''; # so can make a link $blkuse = getparam('blkuse', true); if (nuem($blkuse)) $blkuse = ''; else $tx = 'y'; $pg = '
'.makeForm('pplns')." Block:   Tx:   Dust (Satoshi):   Fee (BTC):   "; } else { $tx = getparam('tx', true); if (nuem($tx) || substr($tx, 0, 1) != 'y') $dotx = false; else $dotx = true; $flds = array('height' => $blk, 'allow_aged' => 'Y'); $msg = msgEncode('pplns', 'pplns', $flds, $user); $rep = sendsockreply('pplns', $msg); if ($rep == false) $ans = array(); else $ans = repDecode($rep); if ($ans['ERROR'] != null) return '
'.$ans['STATUS'].': '.$ans['ERROR'].'
'; $reward_sat = $ans['block_reward']; $miner_sat = round($reward_sat * 0.991); $ans['miner_sat'] = $miner_sat; $data = array( 'Block' => 'block', 'Block Status' => 'block_status', 'Block Hash' => 'block_hash', 'Block Reward (Satoshis)' => 'block_reward', 'Miner Reward (Satoshis)' => 'miner_sat', 'PPLNS Wanted' => 'diff_want', 'PPLNS Used' => 'diffacc_total', 'Elapsed Seconds' => 'pplns_elapsed', 'Users' => 'rows', 'Oldest Workinfoid' => 'begin_workinfoid', 'Oldest Time' => 'begin_stamp', 'Oldest Epoch' => 'begin_epoch', 'Block Workinfoid' => 'block_workinfoid', 'Block Time' => 'block_stamp', 'Block Epoch' => 'block_epoch', 'Newest Workinfoid' => 'end_workinfoid', 'Newest Share Time' => 'end_stamp', 'Newest Share Epoch' => 'end_epoch', 'Network Difficulty' => 'block_ndiff', 'PPLNS Factor' => 'diff_times', 'PPLNS Added' => 'diff_add', 'Share Count' => 'share_count'); $pg = '
Blockchain '.$ans['block']."
\n"; if (strlen($ans['block_extra']) > 0) { $pg .= '
'; $msg = $ans['block_status'].' - '.$ans['block_extra']; $pg .= str_replace(' ', ' ', $msg)."
\n"; } if (strlen($ans['share_status']) > 0) { $pg .= '
'; $msg = $ans['share_status']." - Can't be paid out yet"; $pg .= str_replace(' ', ' ', $msg)."
\n"; } $pg .= "
\n"; $pg .= ''; $pg .= ''; $pg .= ''; $pg .= "\n"; $i = 0; foreach ($data as $dsp => $name) { if (($i++ % 2) == 0) $row = 'even'; else $row = 'odd'; $pg .= ""; $pg .= ""; $pg .= ''; $pg .= "\n"; } $pg .= "
NameValue
$dsp'.$ans[$name].'

\n"; $pg .= ''; $pg .= ''; $pg .= ''; $pg .= ''; $pg .= ''; $pg .= ''; $pg .= ''; $pg .= "\n"; $diffacc_total = $ans['diffacc_total']; if ($diffacc_total == 0) $diffacc_total = pow(10,15); $elapsed = $ans['pplns_elapsed']; $count = $ans['rows']; $tot_pay = 0; for ($i = 0; $i < $count; $i++) { $diffacc_user = $ans['diffacc_user:'.$i]; $diffacc_percent = number_format(100.0 * $diffacc_user / $diffacc_total, 3).'%'; $avg_hash = number_format($diffacc_user / $elapsed * pow(2,32), 0); $pay_sat = floor($miner_sat * $diffacc_user / $diffacc_total); $payaddress = $ans['payaddress:'.$i]; if (($i % 2) == 0) $row = 'even'; else $row = 'odd'; $pg .= ""; $pg .= ''; $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ''; $pg .= ""; $pg .= "\n"; $tot_pay += $pay_sat; } if (($i % 2) == 0) $row = 'even'; else $row = 'odd'; $pg .= ""; $pg .= ''; $pg .= ''; $pg .= ''; $pg .= ''; $pg .= "\n"; $pg .= "
UserDiff Accepted%Avg HashrateBTC -0.9%Address
'.$ans['user:'.$i].'$diffacc_user$diffacc_percent$avg_hash'.btcfmt($pay_sat).'$payaddress
'.btcfmt($tot_pay).'
\n"; if ($dotx === true) $pg .= calctx($ans, $count, $miner_sat, $diffacc_total); } return $pg; } # function show_pplns($page, $menu, $name, $user) { gopage(NULL, 'dopplns', $page, $menu, $name, $user); } # ?>