Electrum – Earlybirds Invest https://earlybirdsinvest.com Latest Crypto News Fri, 18 Jul 2025 01:42:47 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.7 https://i0.wp.com/earlybirdsinvest.com/wp-content/uploads/2024/12/cropped-New-Project-2024-12-17T235703.455.png?fit=32%2C32&ssl=1 Electrum – Earlybirds Invest https://earlybirdsinvest.com 32 32 240146708 Deduce addresses from Electrum Master XPub https://earlybirdsinvest.com/deduce-addresses-from-electrum-master-xpub/ https://earlybirdsinvest.com/deduce-addresses-from-electrum-master-xpub/#respond Fri, 18 Jul 2025 01:42:47 +0000 https://earlybirdsinvest.com/deduce-addresses-from-electrum-master-xpub/

I am developing some code to derive addresses from various master public keys extracted from a series of wallets for some experiments I want to perform. My code can now work with most wallets I’ve tried to use, but Electrum appears to be breaking down as the XPUB that can be extracted from the Electrum App is from m/0h, not from the normal derived path m/84/0/0, so it causes this code.

xpub_str="zpub6restofthekey..."
bip_obj = Bip84.FromExtendedKey(xpub_str, Bip84Coins.BITCOIN)
addr = bip_obj.Change(Bip44Changes.CHAIN_EXT).AddressIndex(index).PublicKey().ToAddress()

To throw the following exception: “Error”: “Public-only vip object depth () below account level or above address index level.”

At first I thought this issue might be using Zpub instead of Xpub, but other wallets like Trezor Suite and Green also used Zpub and managed to generate addresses successfully with the code above.

I would be very grateful if anyone knows how to avoid this problem, or another way to calculate addresses from Electrum XPUB.

]]>
https://earlybirdsinvest.com/deduce-addresses-from-electrum-master-xpub/feed/ 0 48238
Transaction history made to an address via Electrum TestNet wallet is not displayed https://earlybirdsinvest.com/transaction-history-made-to-an-address-via-electrum-testnet-wallet-is-not-displayed/ https://earlybirdsinvest.com/transaction-history-made-to-an-address-via-electrum-testnet-wallet-is-not-displayed/#respond Sat, 31 May 2025 02:33:37 +0000 https://earlybirdsinvest.com/transaction-history-made-to-an-address-via-electrum-testnet-wallet-is-not-displayed/ I’m new to this business so I apologize for such a basic and stupid question. I tried to find the information but couldn’t.

I have made many forwarding to the addresses shown in the following example:

1

Also, my history has these transfers and is marked as successful. For reference, I have transferred it from my wallet to an address linked to the wallet.

2

It is also connected to a test network.

3

As shown, the wallet has everything, everything is fine, but when I try to check the info at my address, there is nothing.

Here we have checked the address through a special website.

4


I wrote a small program to check the address, balance history, but nothing appears there.

Connecting to Electrum server...
Successfully connected to Electrum server.
Address: tb1qc7j5j80s02gupl0qa3svg5kr99smjdq9a7yezd
ScriptHash: bb72dcabbea723d56aa49cd29575e53aaabf832f9dbdb45f251b56e187ce915a
Raw history response: ()
Fetching transaction history...
Found 0 transactions.
Total balance for tb1qc7j5j80s02gupl0qa3svg5kr99smjdq9a7yezd: 0 satoshis (0 BTC)
Current block height: 900621
Disconnected from Electrum server.

Here is the code for the program itself:

import * as bitcoin from 'bitcoinjs-lib';
import { ElectrumClient, ElectrumClientEvents } from '@electrum-cash/network';

const ELECTRUM_HOST = 'blackie.c3-soft.com';
const ADDRESS = 'tb1qc7j5j80s02gupl0qa3svg5kr99smjdq9a7yezd';
const NETWORK = bitcoin.networks.testnet;

function addressToElectrumScriptHash(address: string, network: bitcoin.Network): string | null {
  try {
    const outputScript = bitcoin.address.toOutputScript(address, network);
    const hash = bitcoin.crypto.sha256(outputScript);
    return Buffer.from(hash.reverse()).toString('hex');
  } catch (e) {
    console.error(`Failed to convert address ${address} to scripthash: ${e.message}`);
    return null;
  }
}

async function debugScripthashHistory(client: ElectrumClient<ElectrumClientEvents>, scriptHash: string) {
  try {
    const history = await client.request('blockchain.scripthash.get_history', scriptHash);
    console.log('Raw history response:', JSON.stringify(history, null, 2));
  } catch (error) {
    console.error('Error fetching raw history:', error.message);
  }
}

async function checkAddress() {
  const client = new ElectrumClient(
    'Address Checker',
    '1.4.1',
    ELECTRUM_HOST,
  );

  try {
    console.log('Connecting to Electrum server...');
    await client.connect();
    console.log('Successfully connected to Electrum server.');

    const scriptHash = addressToElectrumScriptHash(ADDRESS, NETWORK);
    if (!scriptHash) {
      console.error('Failed to generate scripthash for address.');
      return;
    }
    console.log(`Address: ${ADDRESS}`);
    console.log(`ScriptHash: ${scriptHash}`);
    await debugScripthashHistory(client, scriptHash);

    console.log('Fetching transaction history...');
    const historyResult = await client.request('blockchain.scripthash.get_history', scriptHash);
    if (historyResult instanceof Error) {
      console.error(`Error fetching history: ${historyResult.message}`);
      return;
    }
    if (!Array.isArray(historyResult)) {
      console.error('Unexpected history response:', historyResult);
      return;
    }

    const history = historyResult as { tx_hash: string; height: number }();
    console.log(`Found ${history.length} transactions.`);

    let totalBalance = 0;
    for (const tx of history) {
      const txHash = tx.tx_hash;
      console.log(`Processing transaction: ${txHash} (Block height: ${tx.height})`);

      const txDataResult = await client.request('blockchain.transaction.get', txHash, true);
      if (txDataResult instanceof Error) {
        console.error(`Error fetching transaction ${txHash}: ${txDataResult.message}`);
        continue;
      }
      if (!txDataResult || typeof txDataResult !== 'object') {
        console.error(`Invalid transaction data for ${txHash}`);
        continue;
      }

      const txData = txDataResult as { vout: { value: string; scriptPubKey: { hex: string } }() };
      const outputScriptHex = bitcoin.address.toOutputScript(ADDRESS, NETWORK).toString('hex');

      for (const vout of txData.vout) {
        if (vout.scriptPubKey.hex === outputScriptHex) {
          const amount = Math.round(parseFloat(vout.value) * 1e8); // Конвертация BTC в сатоши
          totalBalance += amount;
          console.log(`Found output to address: ${amount} satoshis`);
        }
      }
    }

    console.log(`Total balance for ${ADDRESS}: ${totalBalance} satoshis (${totalBalance / 1e8} BTC)`);

    const blockHeightResponse = await client.request('blockchain.headers.subscribe');
    if (blockHeightResponse && typeof blockHeightResponse === 'object' && 'height' in blockHeightResponse) {
      console.log(`Current block height: ${blockHeightResponse.height}`);
    }

  } catch (error) {
    console.error('Error during address check:', error.message);
  } finally {
    try {
      await client.disconnect();
      console.log('Disconnected from Electrum server.');
    } catch (e) {
      console.error('Error during disconnection:', e.message);
    }
  }
}

checkAddress().catch(console.error);
]]>
https://earlybirdsinvest.com/transaction-history-made-to-an-address-via-electrum-testnet-wallet-is-not-displayed/feed/ 0 39254
I’m trying to reproduce a Pre-V2 Electrum address from Nnemonics, but I can’t get the address correctly. Do you have any insights? https://earlybirdsinvest.com/im-trying-to-reproduce-a-pre-v2-electrum-address-from-nnemonics-but-i-cant-get-the-address-correctly-do-you-have-any-insights/ https://earlybirdsinvest.com/im-trying-to-reproduce-a-pre-v2-electrum-address-from-nnemonics-but-i-cant-get-the-address-correctly-do-you-have-any-insights/#respond Wed, 09 Apr 2025 04:26:43 +0000 https://earlybirdsinvest.com/im-trying-to-reproduce-a-pre-v2-electrum-address-from-nnemonics-but-i-cant-get-the-address-correctly-do-you-have-any-insights/

I’m writing a Python program to reproduce wallet addresses from mnemonics, which sounds simple, but I can’t get an old Electrum (Pre-V2) address that matches the address I get from the official GUI wallet.

All the information is useful as it seems that you can’t find too much information about Electrum address generation before V2.

Does anyone have insight into what I’m doing wrong?

import hashlib, ecdsa, base58

def load_wordlist(filename):
    with open(filename, 'r') as f:
        return (word.strip() for word in f.readlines())

# Decoding mnemonic into Electrum v1 seed (entropy)
def mnemonic_to_entropy(mnemonic, wordlist):
    words = mnemonic.split()
    entropy_bits=""
    for word in words:
        index = wordlist.index(word)
        entropy_bits += bin(index)(2:).zfill(11)

    # Pading entropy_bits with zeros to make it byte-aligned
    extra_bits = len(entropy_bits) % 8
    if extra_bits != 0:
        entropy_bits = entropy_bits.ljust(len(entropy_bits) + (8 - extra_bits), '0')

    entropy_hex = hex(int(entropy_bits, 2))(2:).zfill(len(entropy_bits) // 4)
    return bytes.fromhex(entropy_hex)

# Generating private key from entropy + index
def electrum_v1_privkey(entropy, index):
    data = entropy + index.to_bytes(4, 'little')
    return hashlib.sha256(data).digest()

# Converting private key to compressed public key
def privkey_to_pubkey(privkey):
    sk = ecdsa.SigningKey.from_string(privkey, curve=ecdsa.SECP256k1)
    vk = sk.verifying_key
    prefix = b'\x02' if vk.to_string()(-1) % 2 == 0 else b'\x03'
    return prefix + vk.to_string()(:32)

# Converting public key to address
def pubkey_to_address(pubkey):
    sha256_pubkey = hashlib.sha256(pubkey).digest()
    ripemd160_pubkey = hashlib.new('ripemd160', sha256_pubkey).digest()
    prefixed_pubkey = b'\x00' + ripemd160_pubkey
    checksum = hashlib.sha256(hashlib.sha256(prefixed_pubkey).digest()).digest()(:4)
    return base58.b58encode(prefixed_pubkey + checksum).decode()

mnemonic = "sample mnemonic"
wordlist = load_wordlist('old_electrum_wordlist')

entropy = mnemonic_to_entropy(mnemonic, wordlist)

# Generating first 5 addresses
for index in range(5):
    privkey = electrum_v1_privkey(entropy, index)
    pubkey = privkey_to_pubkey(privkey)
    address = pubkey_to_address(pubkey)
    print(f'Address {index}: {address}')

]]>
https://earlybirdsinvest.com/im-trying-to-reproduce-a-pre-v2-electrum-address-from-nnemonics-but-i-cant-get-the-address-correctly-do-you-have-any-insights/feed/ 0 29814