Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [bitcoinjs]

BitcoinJS (bitcoinjs-lib) is JavaScript Bitcoin library.

Filter by
Sorted by
Tagged with
1 vote
0 answers
18 views

how to get vsize before psbt finalized

I am using bitcoinjs-lib to construct a transaction through PSBT, but I am having difficulty obtaining the virtual size (vsize). My process is as follows: Obtain the user's address through the ...
user151983's user avatar
0 votes
0 answers
16 views

how to calclate the fee of a segwit transaction? [duplicate]

I am using bitcoin-js to construct a PSBT transaction. Suppose address A has 10 UTXOs, each containing 0.0001 BTC. Now I want to construct a transaction to send 0.0005 BTC to address B. If I use 5 of ...
user151983's user avatar
0 votes
0 answers
15 views

How to create a litecoin testnet segwit wallet offline [closed]

Hi So I am using the bitcoinjs-lib pacakge to generate wallet address and private keys locally but it seems like it's creating the litecoin address of legacy type, my goal is here to create of segwit ...
Sudhanshu Sinha's user avatar
1 vote
1 answer
37 views

broadcast ps2wsh transaction failed

Greeting, I hope someone can guide me about what is wrong with my p2wsh transaction hex below ...
ron s's user avatar
  • 13
0 votes
1 answer
148 views

bitcoinjs - mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)

I'm trying to follow the below transaction example by magic eden and extend it to support multiple buyers and seller (in red). However I am having difficulties when I add more than one signature from ...
psbt_trustless_tx's user avatar
1 vote
1 answer
136 views

How to use BlockCypher's test network with BitcoinJS-lib?

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 ...
1owk3y's user avatar
  • 115
-1 votes
1 answer
71 views

Transaction sending failed (No script found for input #0)

I tried to make a simple btc transfer but i got this error: No script found for input #0. What did i miss? const bitcoin = require("bitcoinjs-lib"); const ECPairFactory = require("...
István Tóth's user avatar
3 votes
1 answer
104 views

Mnemonic from Node.js app not restoring in other wallets

I'm working on a Node.js app that makes RPC calls to my node, and I'm having trouble restoring a mnemonic created with bitcoinjs-lib, bip32, and bip39. First, I create a blank wallet that accepts ...
Cannabijoy's user avatar
2 votes
1 answer
147 views

non-mandatory-script-verify-flag (Invalid Schnorr signature) when trying to reveal a TR output

I'm building a Bitcoin wallet, and I'm trying to spend a Taproot output via a script spend path, but I keep running into this "Invalid Schnorr signature" error from my RPC node: { "...
Sherwin Li's user avatar
2 votes
1 answer
171 views

Estimating virtual bytes of a transaction seems circular

I'm sorry if this has been answered before, but I haven't found anyone really bring this up. I am trying to construct a PSBT, which assumes a fixed feerate and a fixed amount to send to some address. ...
Sherwin Li's user avatar
2 votes
1 answer
328 views

"Witness program hash mismatch" code -26 when broadcasting a transaction

I'm trying to broadcast a transaction to my RPC provider: curl https://my-quicknode-rpc-provider/ \ -X POST \ -H "Content-Type: application/json" \ --data '{"method": &...
Sherwin Li's user avatar
2 votes
1 answer
155 views

Getting Error while trying to decode psbt base64 to json using bitcoinjs/bip174 library

const base64PSBT = 'base_64'; // Decode the base64 PSBT to a Buffer const psbtBuffer = Buffer.from(base64PSBT, 'base64'); // Parse the PSBT const psbt = bip174.Psbt.fromBuffer(psbtBuffer); // ...
soumyadeep.eth's user avatar
0 votes
1 answer
209 views

Redeem script for input #0 doesn't match the scriptPubKey in the prevout

I'm trying to create a new bitcoin transaction using bitcoinjs-lib. Here is my transaction. { "weight" : 661, "txid" : "...
Berry Blue's user avatar
3 votes
1 answer
906 views

How to build a transaction using bitcoinjs-lib

I'm trying to build a transaction using bitcoinjs-lib. Here is my last transaction. https://blockstream.info/api/tx/91feea5f5c7b67b3e56c0f5d23d6da3065855c23b4cc7dded8efd8ff8065500f { "weight&...
Berry Blue's user avatar
0 votes
0 answers
119 views

Why is this Ordinals transaction I sent wrong, can anyone help me?

let content_type = "text/plain;charset=utf-8"; let body = Buffer.from("000"); const inscription = { body, content_type, }; const network = bitcoin....
lari fa's user avatar
1 vote
1 answer
566 views

Webpack issue with tiny-secp256k1 and ECPair

I am developing a browser extension using Webpack v5 and incorporating the bitcoinjs-lib and ecpair libraries to create a Bitcoin wallet. However, I am encountering an error when attempting to load ...
Vaibhav Patel's user avatar
0 votes
0 answers
30 views

bitcoin.Psbt doesn't auto-display its method/properties in Visual Studio Code

When instantiating a new Psbt in my Visual Studio Code like below: const psbt = new bitcoin.Psbt() The variable psbt doesn't auto display any of its methods/properties after I add the . right after ...
jiamijiang's user avatar
1 vote
0 answers
95 views

Is there such a bip32 function?

I have this code: const bip32 = utils.BIP32Factory(utils.ecc) const mnemonic = utils.bip39.generateMnemonic(256); const seed = utils.bip39.mnemonicToSeedSync(mnemonic); const masterNode = bip32....
AlexCav's user avatar
  • 51
-1 votes
1 answer
773 views

bitcoinjs-lib is installed but cannot use its functions

I've installed the latest version of bitcoinjs-lib but I cannot use the functions of the library. const bitcoin = require('bitcoinjs-lib'); const keyPair = bitcoin.ECPair.makeRandom(); const { address ...
Tornike Tskhvediani's user avatar
0 votes
1 answer
217 views

testnet output address has no matching Script?

Here is my code to create a PSBT on the testnet: const bitcoin = require("bitcoinjs-lib") const privKey1 = "..." const address1 = "mkVPHMR5euGTcvpFj6tfyVERstDdH4RtQs" ...
jiamijiang's user avatar
1 vote
1 answer
78 views

problem sending relative locktime (OP_CSV) transaction

i tried making a relative timelocked transaction with 1 block timelock (spendable after 1 confirmation) funding tx: 0fda5412da2a2615361914fad007aac73154746108d44c04529e78f6c4424655 address: ...
Antoni's user avatar
  • 287
1 vote
0 answers
29 views

How to secure exchange hot wallet keys

Am currently working on an exchange, am building the hot wallet using bitcoinjs-lib. I generate my wallet pub /sec keys and addresses using this library (I don't want to use wallet.dat file). Now is ...
Chisom Maxwell's user avatar
-1 votes
1 answer
2k views

How to read the balance on a wallet address [closed]

So, first of all i will be creating these wallet addresses on my end using below code: const diviMainnet = { messagePrefix: '\x19Divi Signed Message:\n', ...
Moblize IT's user avatar
1 vote
0 answers
281 views

Error validating transaction ... Script was NOT verified successfully

I'm getting this error below when trying to broadcast a transaction with the code below. I'm new to blockchain development and I've been trying to solve this but can't seem to figure it out. I believe ...
helpme123's user avatar
0 votes
1 answer
765 views

In bip32-utils for bitcoinjs, node.getAddress is not a function

I am trying to run the example code in the bip32-utils taken here (https://github.com/bitcoinjs/bip32-utils) of: const bip39 = require('bip39') const bitcoin = require('bitcoinjs-lib') const ...
jiamijiang's user avatar
1 vote
2 answers
623 views

Storing entire seed from bip39 mnemonic using WIF

I'm using the bitcoinjs collection of libraries, specifically https://github.com/bitcoinjs/wif, https://github.com/bitcoinjs/bip32 and https://github.com/bitcoinjs/bip39 with nodejs. I have a mnemonic ...
Infinite Recursion's user avatar
0 votes
2 answers
505 views

Missing Witness field in p2wpkh decoded tx hex

I have placed together a raw tx hex but when it's unable to be broadcasted as I keep getting an error below sendrawtransaction RPC error: {"code":-25,"message":"bad-txns-...
jiamijiang's user avatar
0 votes
1 answer
149 views

What are some different ways to retrieve btc transaction information of an address using bitcoinjs?

What are some different ways to retrieve btc transaction information of an address using bitcoinjs? I've tried using the syntax from this page (https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/...
jiamijiang's user avatar
0 votes
0 answers
965 views

Need help with (Script failed an OP_EQUALVERIFY operation)

This is a repost of a question which i posted directly on the repository of bitcoinjs-lib, which you can see here I'm getting the following error when trying to push transactions: Err: ...
JakGuru's user avatar
0 votes
0 answers
146 views

How to get raw tx in hex format by not fetching API from provider?

I've looking for some solution to encode raw transaction in hex format by programmatically without fetching data from any blockchain provider. Are there any way to do this?
Vintage Beef's user avatar
0 votes
1 answer
922 views

Can we sign a psbt raw tx having multiple inputs created from BTC node with bitcoinjs lib?

Due to secruity reasons, unavailablity of private keys on my end and as per project requirements I need to build back end apis where I will provide a PSBT raw transaction hex (having multiple inputs) ...
Surinder kumar's user avatar
1 vote
0 answers
208 views

How can I use PSBT in a JavaScript project?

I am trying to use PSBT in a Bitcoin project. The idea is to generate keys and sign transactions client-side. I am already familiar with bitcoinjs-lib but I find the API rather complicated. It would ...
Mario Mazzola's user avatar
1 vote
0 answers
121 views

How to use Digital Signature to Sign Unsigned Transaction?

so I was trying to sign my unsigned transaction: ...
coder123's user avatar
  • 113
1 vote
2 answers
485 views

How to verify the compressed signature in Bitcoin? It is 138 long in hex

I am using the bicoinjs-message npm module for signature verification. I learned that there are few signatures which are of length 138 in hexadecimal. When I tried to verify such a signature it is ...
Shubham Chadokar's user avatar
2 votes
1 answer
362 views

How to fetch all UTXO from a SPV wallet using bitcoin-filter.js (or other lib)?

I am using bitcoinjs-lib to create private key (WIF), addresses and sign the transactions. I would like to fetch all transactions (UTXOs) associated with a wallet. I found these libs: bitcoin-filter ...
le0's user avatar
  • 187
1 vote
1 answer
677 views

How to calculate fee in BitcoinJS raw transaction?

I have a transaction with 3 inputs and 2 outputs. 1output is the recipient and the other output is change address. How should I calculate the fee and apply it to output?
Amirhosein Rajabi's user avatar
1 vote
1 answer
998 views

Bitcoinjs-lib how to add multiple utxos in addInput

Hi i want to make transactions of bitcoin bech32 addresses using bitcoinjs-lib , here is my code below, it works fine when my address has only one utxos but when it increases to two or more as its ...
Hamza Yasin's user avatar
0 votes
1 answer
113 views

How to do tx.addInput without tx_hash if sending from address for the first time?

Iam using the bitcoinjs-lib library and trying to do a transaction. Iam doing the tx.addInput method before building but running into a build issue. I assume an error is thrown if ...
jwjop1's user avatar
  • 1
3 votes
3 answers
2k views

How do you switch your bitcoinjs integrationfrom TransactionBuilder to transactions-psbt.js?

the code below works: const btc = require('bitcoinjs-lib'); var tx = new btc.TransactionBuilder(net); inputs.forEach(o => tx.addInput(o.txId, o.vout)); outputs.forEach(o => tx.addOutput(o....
ekkis's user avatar
  • 177
0 votes
2 answers
253 views

How to get BTC transfer amount from raw tx using bitcoinjs

Suppose I have following object console.log(bitcoinjs.Transaction.fromHex(rawTx)); The output Transaction { version: 2, locktime: 1655960, ins: [ { hash: <Buffer dc 4d aa 10 db ...
Michael Khoroshun's user avatar
1 vote
1 answer
1k views

Tracking incoming transactions using nodejs and own node

I need to verify that user from my database has sent btc to my wallet. Ideally I want to generate a unique address for each user transaction and then track all those addresses but I suppose it will ...
idknabit's user avatar
1 vote
1 answer
1k views

Cannot sign txn with change address using bitcoinjs-lib psbt

I am having a difficult time figuring out how to sign a spend from a change address. I get Error: cannot sign for this input with the key <value>. The initial transaction works fine, where I ...
GViz's user avatar
  • 143
0 votes
2 answers
160 views

How can I consume my whole bitcoin balance in a single transction? Is it possible to use multiples UTXOs in a single transaction?

I want to make use of a single bitcoin address for payment. I'm using bitcoinjs library's transction builder for creating my own transaction. Can anyone help with a proper code to use multiple UTXO's ...
AditiB's user avatar
  • 111
0 votes
1 answer
1k views

Why do I get: Error: <address> has no matching Script

The example code for psbt.addOutput() with address '1KRMKfeZcmosxALVYESdPNez1AP1mEtywp' works as expected. But if I change this to an testnet address I get this error: ' has no matching script'. I ...
NoudS's user avatar
  • 1
0 votes
1 answer
453 views

How to get Bitcoin input transaction hash string from bitcoinjslib Transaction object?

I'm using bitcoinjs-lib and its Transaction object. Transaction.ins is an array of objects, each which has a hash and script property. Both of these properties are Uint8Arrays. I am trying to get ...
danosphere's user avatar
0 votes
0 answers
165 views

Sign a Partially Signed rawtransaction with bitcoinjs-lib

I was trying to figure out how to use the bitcoinjs-lib. I was thinking if I could sign a partially signed raw transaction in bitcoijs-lib. For example - If I have a hex String whose input1 is ...
Shubham Saxena's user avatar
2 votes
0 answers
371 views

How to send & receive bitcoin using bitcoinjs-lib?

First I create HD Wallet using BIP32 using mnemonics. Now I want to generate new child addresses with private key using xpub & xpriv for every receive. Then for example, I received BTC in 2 ...
Monarth Sarvaiya's user avatar
0 votes
3 answers
2k views

how to generate bitcoin adddres using seed?

Hi i am new to bitcoin all i want to know is how to generate address using mnemonic seed? let testnet =Bitcoin.networks.testnet; let keypair =Bitcoin.ECPair.makeRandom({network:testnet}); let address=...
syeda Roushan Arshid's user avatar
1 vote
1 answer
2k views

How to retrieve readable private key from bitcoinjs-lib

I'm still new to bitcoin and experimenting a lot with bitcoinjs-lib in JavaScript. How do I create a readable string from a private key? This is my current setup: const seed = bip39....
mesqueeb's user avatar
  • 131
0 votes
1 answer
708 views

Cannot read property 'toWIF' of undefined

I am working on a cryptocurrency site in which each user will have there own individual deposit address to put currency on site. I am using bitcoin-core, bitcoinjs-lib, along with quite a few other ...
Mason's user avatar
  • 1