in

Retrieving balance of Taproot address from Electrum Server

Have I understood the concept of address, account and wallet correctly and how the wallet balance is calculated?

[ad_1]

I’m having troubles retrieving the balance of taproot addresses from a self-hosted Electrs (Electrum Server).

First of all I’m getting the scriptPubKey from Bitcoin Core:

{
  "isvalid": true,
  "address": "...",
  "scriptPubKey": "...",
  "isscript": true,
  "iswitness": true,
  "witness_version": 1,
  "witness_program": "..."
}

Then I’m using this PHP code to query the balance from the Electrs server:

$addrScripthash = hash('sha256', hex2bin($address_info['scriptPubKey']));
$re="/.{2}/";
preg_match_all($re, $addrScripthash, $matches, PREG_PATTERN_ORDER, 0);
$addrScripthash = implode('', array_reverse($matches[0]));

$electrs->sendRequest('blockchain.scripthash.subscribe', array($addrScripthash))->result;

var_export($electrs->sendRequest('blockchain.scripthash.get_balance', array($addrScripthash))->result);

Unfortunately it seems to hang while it used to work just fine with Segwit addresses. Am I doing something wrong?

[ad_2]

Source link

Written by BTC Artist

Leave a Reply

Your email address will not be published. Required fields are marked *

Ripple Vs. SEC Saga: Legal Expert Unravels The “Bigger Argument”

MetaMask expands global reach with new partnerships in six countries

What is MetaMask? | Is MetaMask safe?