I am trying to create PSBT through 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.
When you create a new address using BlockCypher’s API, address
, private
, public
and wif
(In their document wif
But it actually gives you one…)
Below is an example response:
"private": "9125ea9f573e23ce178d98cc2ec2a78655bd030c14b525729a026d6570b411c8",
"public": "03f1fbc34305c61d7638c449030c32a66eb36726c208fca9962923a98ca75d77fe",
"address": "C1E96vE5GvKd5kXU4T4hhF6QioZzACrmdD",
"wif": "BtCBNtS2noEXwm4rJi9nyiVbmZJMR9CEBMbF5Uz6JTSaR9EQn8jS"
However, none of this information can be used on its own. sign
Functions in BitcoinJS-lib require a signer (KeyPair
) class object..providing the private key on its own will not work.
in other words psbt.signInput(0, privateKey);
The results are as follows: Error: Need Signer to sign input
I am KeyPair
It comes from WIF, but because BitcoinJS-lib lacks WIF bitcoin.networks
Configuration suitable for bcy/test
It doesn’t always work out…
ECPair.fromWIF(wif, bitcoin.networks.testnet); // Error: Invalid network version
ECPair.fromWIF(wif, bitcoin.networks.main); // Error: Invalid network version
ECPair.fromWIF(wif); // Error: Invalid network version
The error message indicates that WIF is not possible on the network you are trying.
How do I make it? KeyPair
for bcy/test
?