How BitcoinJS sync bitcoin blockchain/transaction data?

0

I see the reference code in BitcoinJS website about 'Creating a Transaction':

var tx = new bitcoin.TransactionBuilder()

// Add the input (who is paying):
// [previous transaction hash, index of the output to use]
var txId = 'aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31'
tx.addInput(txId, 0)

My question is how it get the data about tx(like its inputs/outputs)? Does it link to some nodes or API like blockchain.info?

Anderson

Posted 2017-11-27T09:22:28.540

Reputation: 115

Maybe it's just a SPV node?Anderson 2017-11-27T09:45:12.917

Answers

1

BitcoinJS does not link directly to the bitcoin network, it is simply a collection of bitcoin-related functions.

Taking your example above, if we wanted to create a transaction with BitcoinJS' transaction builder function, we would have to find the inputs ourselves via API's (or asking your own full node if you have one) and add then it with tx.addInput(txId, 0).

timothyylim

Posted 2017-11-27T09:22:28.540

Reputation: 313