<p>Oops! Noob mistake.</p>

<p>I thought that testnet and regtest had different version prefixes (not compatible) <strong>but they are</strong> (the bitcoin wiki and bitcoin developers page doesn't clarify this, though). So I went into a npm package that added dogecoin and litecoin testnets compatibility with bitcoinjs-lib (it's called bitcoinjs-testnets).</p>

<p>But the solution in the second Github link that I posted works. </p>

<p>Here I repost the text:</p>

<blockquote>
  <p>Just want to give some feedback that may help new users in the future.
  I lost a lot of time debugging an issue that is probably extremely
  obvious to some, but it was not directly obvious to me.</p>
</blockquote>

<pre><code>var bitcoin = require("bitcoinjs-lib");
var keyPair = bitcoin.ECPair.fromWIF("mywif", bitcoin.networks.testnet);
var txb = new bitcoin.TransactionBuilder(); txb.addOutput("myaddress", satoshis);  // &lt;---- this will fail with "has no matching Script"
</code></pre>

<blockquote>
  <p>Because of the error message I came to the conclusion that I was doing
  something fundamentally wrong creating the transaction. In the end, it
  turns out I just needed </p>
</blockquote>

<pre><code>var txb = new bitcoin.TransactionBuilder(bitcoin.networks.testnet);
</code></pre>

<blockquote>
  <p>Feel free to close this, just wanted to share my experience</p>
</blockquote>

<p>I wish my noob experience has helped you! (pardon for my english).</p>

CC BY-SA 3.0
2016-10-29T18:53:09.660Z
2016-11-01T21:56:18.250Z
2016-11-01T21:56:18.250Z
joe.js
<p>I was trying to use the bitcoinjs-lib (1) with my regtest network. More specifically I was trying to build a tx with TransactionBuilder but it gave me a 'transaction has no matching Script' exception. </p>

<p>In a closed github issue (2) I find out that it's possible to specify the network (network.testnet), but I can't find any documentation related to regtest. I just want to create and broadcast a raw tx created with bitcoinjs to my regtest network. </p>

<p>So, has anyone talked to a regtest network with bitcoinjs-lib successfully? If not, what other libs would you recommend for the satoshi client? Thanks.</p>

<p>(1) <a href="https://github.com/bitcoinjs/bitcoinjs-lib" rel="noreferrer">https://github.com/bitcoinjs/bitcoinjs-lib</a></p>

<p>(2) <a href="https://github.com/bitcoinjs/bitcoinjs-lib/issues/500" rel="noreferrer">https://github.com/bitcoinjs/bitcoinjs-lib/issues/500</a></p>

<bitcoin-core><regtest><bitcoinjs>
How to use bitcoinjs-lib with Regtest?
joe.js
# How to use bitcoinjs-lib with Regtest?

(Asked by: username_0 on 2016-10-27)

I was trying to use the bitcoinjs-lib (1) with my regtest network. More specifically I was trying to build a tx with TransactionBuilder but it gave me a 'transaction has no matching Script' exception.

In a closed github issue (2) I find out that it's possible to specify the network (network.testnet), but I can't find any documentation related to regtest. I just want to create and broadcast a raw tx created with bitcoinjs to my regtest network.

So, has anyone talked to a regtest network with bitcoinjs-lib successfully? If not, what other libs would you recommend for the satoshi client? Thanks.

(1) <https://github.com/bitcoinjs/bitcoinjs-lib>

(2) <https://github.com/bitcoinjs/bitcoinjs-lib/issues/500>

**Tags:** bitcoin-core, regtest, bitcoinjs


---

## 1 answers

### Answer by username_0 on 2016-10-29. Score: 3

Oops! Noob mistake.

I thought that testnet and regtest had different version prefixes (not compatible) **but they are** (the bitcoin wiki and bitcoin developers page doesn't clarify this, though). So I went into a npm package that added dogecoin and litecoin testnets compatibility with bitcoinjs-lib (it's called bitcoinjs-testnets).

But the solution in the second Github link that I posted works.

Here I repost the text:

> Just want to give some feedback that may help new users in the future.
> I lost a lot of time debugging an issue that is probably extremely
> obvious to some, but it was not directly obvious to me.

```
var bitcoin = require("bitcoinjs-lib");
var keyPair = bitcoin.ECPair.fromWIF("mywif", bitcoin.networks.testnet);
var txb = new bitcoin.TransactionBuilder(); txb.addOutput("myaddress", satoshis);  // <---- this will fail with "has no matching Script"

```

> Because of the error message I came to the conclusion that I was doing
> something fundamentally wrong creating the transaction. In the end, it
> turns out I just needed

```
var txb = new bitcoin.TransactionBuilder(bitcoin.networks.testnet);

```

> Feel free to close this, just wanted to share my experience

I wish my noob experience has helped you! (pardon for my english).


---

