bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.71k stars 2.11k forks source link

Tesnet: is not a valid bitcoin testnet address #2116

Closed A2DNEW closed 4 months ago

A2DNEW commented 4 months ago

i use this code and i can get testnet address:

const keyPair = ECPair.makeRandom({
      network: bitcoin.networks.testnet,
    });

    const result = bitcoin.payments.p2pkh({
      pubkey: keyPair.publicKey,
      network: bitcoin.networks.testnet,
    });

    console.log(result.address);

i try to get faucet from https://bitcoinfaucet.uo1.net/send.php but i get error: is not a valid bitcoin testnet address

but addresses start with tb works fine

junderw commented 4 months ago

They don't support P2PKH.

"is not valid" is a lie. It should be "We do not support P2PKH" instead.

A2DNEW commented 4 months ago

They don't support P2PKH.

"is not valid" is a lie. It should be "We do not support P2PKH" instead.

How can I receive faucet for P2PKH?

acsonservice commented 4 months ago

To obtain testnet coins for P2PKH addresses, you can use a Bitcoin testnet faucet. Here's how you can do it:

  1. Set Up a Testnet Wallet: Ensure you have a Bitcoin wallet that supports the testnet. Popular wallets like Electrum, Bitcoin Core, and others have testnet options.

  2. Generate a Testnet Address:

    • For Electrum, you can start it in testnet mode by running electrum --testnet.
    • For Bitcoin Core, you can start it in testnet mode by running bitcoin-qt -testnet or bitcoind -testnet.
  3. Find a Testnet Faucet: There are several online testnet faucets that provide free testnet BTC. Some reliable ones include:

  4. Request Testnet Coins:

    • Visit the faucet website.
    • Enter your testnet Bitcoin address (P2PKH format starts with 'm' or 'n').
    • Complete any captcha or verification process required.
    • Click the button to request testnet BTC.
  5. Receive Testnet BTC: The requested testnet BTC should be sent to your address within a few minutes. You can verify the receipt by checking your wallet or using a testnet block explorer like Blockstream Testnet Explorer.

Here’s a step-by-step example using the CoinFaucet.eu:

  1. Go to CoinFaucet.eu.
  2. Enter your testnet Bitcoin address.
  3. Solve the CAPTCHA.
  4. Click on the "Get Testnet Coins" button.

By following these steps, you should be able to get testnet BTC for your P2PKH address and start testing your transactions on the Bitcoin testnet.