function get_address_balance($btcaddress) {
$output = shell_exec("electrum getaddressbalance ".escapeshellarg($btcaddress));
if ($output=='daemon is not connected'){return False;}
$balances = objectToArray(json_decode($output));
// $balances['confirmed'] and $balances['unconfirmed'];
return $balances;
}
This piece of code can take a very long time to execute, usually a minimum of one second but normally much longer than that. what is the best way to do this?
If you want to go faster, you need to be asking a long-running daemon process of some kind, not an electrum client.