public function get_rows($start = 0) { // Get rows to display $bip32 = new bip32(); $rows = DB::query("SELECT * FROM coin_wallets WHERE status = 'active' ORDER BY id"); // Go through rows $results = array(); foreach ($rows as $row) { $row['checkbox'] = "<center><input type=\"checkbox\" name=\"wallet_id[]\" value=\"{$row['id']}\"></center>"; $row['balance'] = $bip32->get_balance($row['id']) . ' BTC'; if ($row['address_type'] == 'multisig') { $row['address_type'] = 'Multisig - ' . $row['sigs_required'] . ' of ' . $row['sigs_total']; } else { $row['address_type'] = 'Standard'; } array_push($results, $row); } // Add total $total = DB::queryFirstField("SELECT count(*) FROM coin_wallets WHERE status = 'active'"); if ($total > 1) { // Get balance $total_balance = DB::queryFirstField("SELECT sum(amount) FROM coin_inputs WHERE is_spent = 0"); if ($total_balance == '') { $total_balance = 0; } // Set vars $vars = array('checkbox' => " ", 'id' => " ", 'display_name' => '<b>Total</b>', 'address_type' => " ", 'balance' => '<b>' . fmoney_coin($total_balance) . ' BTC</b>'); array_push($results, $vars); } // Return return $results; }
$template->add_message('Successfully verified public keys, and all private keys match appropriately.'); } } // Initialize $bip32 = new bip32(); // Get wallets $first = true; $bip32_key_fields = ''; $required_sigs = 0; $wallet_id = 0; $wallet_javascript = ''; $wallet_options = ''; $rows = DB::query("SELECT * FROM coin_wallets WHERE status = 'active' ORDER BY display_name"); foreach ($rows as $row) { $wallet_id = $row['id']; $balance = $bip32->get_balance($row['id']); $wallet_options .= "<option value=\"{$row['id']}\">{$row['display_name']} ({$balance} BTC)"; $wallet_javascript .= "wallets['" . $row['id'] . "'] = " . $row['sigs_total'] . ";\n\t"; // Create BIP32 key fields, if needed if ($first === true) { for ($x = 1; $x <= $row['sigs_total']; $x++) { $name = $x == 1 ? 'BIP32 Private Key:' : 'BIP32 Private Key ' . $x . ':'; $bip32_key_fields .= "<tr><td>{$name}</td><td><textarea name=\"verify_private_key" . $x . "\"></textarea></td></tr>"; } $required_sigs = $row['sigs_total']; $first = false; } } // Template variables $template->assign('balance', $balance); $template->assign('has_multiple_wallets', count($rows) > 1 ? true : false);