Web Interstitial Ad Example

javascript – How to use BlockCypher’s test network with BitcoinJS-lib?

Stardew Valley Mod Apk 3

[ad_1]

Trying to make a PSBT via BitcoinJS-lib.

I’m using BlockCypher’s internal testnet (bcy/test) because I have no choice: literally every other testnet faucet I tested was broken.

Using BlockCypher’s API to make new addresses, they give you an address, private, public and wif

(their documentation doesn’t mention the wif, but it does indeed give one…)

Here’s an example response

{
  "private": "9125ea9f573e23ce178d98cc2ec2a78655bd030c14b525729a026d6570b411c8",
  "public": "03f1fbc34305c61d7638c449030c32a66eb36726c208fca9962923a98ca75d77fe",
  "address": "C1E96vE5GvKd5kXU4T4hhF6QioZzACrmdD",
  "wif": "BtCBNtS2noEXwm4rJi9nyiVbmZJMR9CEBMbF5Uz6JTSaR9EQn8jS"
}

However none of this information is usable on it’s own because the sign functions of BitcoinJS-lib expect a Signer (KeyPair) class object.. giving it a private key on it’s own doesn’t work.

i.e. psbt.signInput(0, privateKey); results in: Error: Need Signer to sign input

I tried to make a KeyPair out of a WIF, but because BitcoinJS-lib lacks the bitcoin.networks configuration appropriate for bcy/test it always fails to resolve..

ECPair.fromWIF(wif, bitcoin.networks.testnet); // Error: Invalid network version
ECPair.fromWIF(wif, bitcoin.networks.bitcoin); // Error: Invalid network version
ECPair.fromWIF(wif); // Error: Invalid network version

The error message suggests the WIF is not possible on those attempted networks.

How do I make a KeyPair for bcy/test ?

[ad_2]

Source link