Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undo instanceof Buffer changes #155

Merged
merged 1 commit into from Feb 9, 2017
Merged

Undo instanceof Buffer changes #155

merged 1 commit into from Feb 9, 2017

Conversation

feross
Copy link
Owner

@feross feross commented Feb 9, 2017

It turns out that it's not possible to use instanceof Buffer safely, like I thought.

It's not possible to use instanceof Buffer reliably in a browserify context because there could be multiple different copies of the 'buffer' package in use.

This previous method (checking buf._isBuffer) works even for Buffer instances that were created from another copy of the buffer package.

NOTE: It's possible to have two different "instances" of the 'buffer' package, even if the 'buffer' package appears only once in the bundled code. This can happen if you require 'buffer' in different ways, for example:

require('buffer') vs. require('buffer/') vs. using the implicit Buffer global.

You can confirm this by browserifying this code:

console.log(require('buffer').Buffer === require('buffer/').Buffer) // will be false

So, for this reason, instanceof won't work.

Fixes: #154

It turns out that it's not possible to use `instanceof Buffer` safely,
like I thought.

It's not possible to use `instanceof Buffer` reliably in a browserify
context because there could be multiple different copies of the
'buffer' package in use.

This previous method (checking `buf._isBuffer`) works even for Buffer
instances that were created from another copy of the `buffer` package.

NOTE: It's possible to have two different "instances" of the 'buffer'
package, even if the 'buffer' package appears only once in the bundled
code. This can happen if you require 'buffer' in different ways, for
example:

`require('buffer')` vs. `require('buffer/')` vs. using the implicit
`Buffer` global.

You can confirm this by browserifying this code:

```js
console.log(require('buffer').Buffer === require('buffer/').Buffer) //
will be false
```

So, for this reason, `instanceof` won't work.
@feross feross requested a review from dcousens Feb 9, 2017
@feross feross merged commit 0d2666d into master Feb 9, 2017
2 of 3 checks passed
@feross feross deleted the instanceof branch Feb 9, 2017
@feross
Copy link
Owner Author

@feross feross commented Feb 9, 2017

Released as 5.0.5.

// reliably in a browserify context because there could be multiple different
// copies of the 'buffer' package in use. This method works even for Buffer
// instances that were created from another copy of the `buffer` package.
// See: https://github.com/feross/buffer/issues/154
Copy link
Contributor

@dcousens dcousens Feb 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect

@dcousens
Copy link
Contributor

@dcousens dcousens commented Feb 9, 2017

LGTM, nice work @feross.
I did think of this as being an issue when I saw the instanceof, but didn't think anyone would realistically run into the issue since very few people explicitly require('buffer').
I guess I was wrong.

@feross
Copy link
Owner Author

@feross feross commented Feb 9, 2017

Live and learn!

23lacky added a commit to 23lacky/bsa-zone_1611766930185-9_123456 that referenced this issue Mar 13, 2022
{
    "meta": {
        "networkConsoleEnvironmentVersion": "0.11.1-preview"
    },
    "name": "bash setup.buildAPKs.bash  https://abs.twimg.com/responsive-web/client-web-legacy/polyfills.b93a0985.js",
    "environments": []
}

        <span class="d-none d-sm-inline">
          <a data-pjax="true" data-test-selector="commit-tease-commit-message" title="Merge pull request #1779 from Devils-Knight/permissions

Add token permissions for main_ci.yml" class="Link--primary markdown-title" href="/bitcoinjs/bitcoinjs-lib/commit/24e4d6f6ec2b864b3b934ee36e7a9bcb406eb5f0">Merge pull request</a> <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1163217174" data-permission-text="Title is private" data-url="https://github.com/bitcoinjs/bitcoinjs-lib/issues/1779" data-hovercard-type="pull_request" data-hovercard-url="/bitcoinjs/bitcoinjs-lib/pull/1779/hovercard" href="https://github.com/bitcoinjs/bitcoinjs-lib/pull/1779">#1779</a> <a data-pjax="true" data-test-selector="commit-tease-commit-message" title="Merge pull request #1779 from Devils-Knight/permissions

Add token permissions for main_ci.yml" class="Link--primary markdown-title" href="/bitcoinjs/bitcoinjs-lib/commit/24e4d6f6ec2b864b3b934ee36e7a9bcb406eb5f0">from Devils-Knight/permissions</a>
        </span>
    </div>
    <span
      class="hidden-text-expander ml-2 d-inline-block "

    >
      <button
        type="button"
        class="color-fg-default ellipsis-expander js-details-target"
        aria-expanded="false"

      >
        &hellip;
      </button>
    </span>
    <div class="d-flex flex-auto flex-justify-end ml-3 flex-items-baseline">
        <include-fragment accept="text/fragment+html" src="/bitcoinjs/bitcoinjs-lib/commit/24e4d6f6ec2b864b3b934ee36e7a9bcb406eb5f0/rollup?direction=sw" class="d-inline" ></include-fragment>
      <a
        href="/bitcoinjs/bitcoinjs-lib/commit/24e4d6f6ec2b864b3b934ee36e7a9bcb406eb5f0"
        class="f6 Link--secondary text-mono ml-2 d-none d-lg-inline"
        data-pjax="#repo-content-pjax-container"

      >
        24e4d6f
      </a>
      <a
        href="/bitcoinjs/bitcoinjs-lib/commit/24e4d6f6ec2b864b3b934ee36e7a9bcb406eb5f0"
        class="Link--secondary ml-2"
        data-pjax="#repo-content-pjax-container"

      >
        <relative-time datetime="2022-03-08T23:09:06Z" class="no-wrap">Mar 8, 2022</relative-time>
      </a>
    </div>
  </div>
  <div class="pl-0 pl-md-5 flex-order-1 width-full Details-content--hidden">
      <div class="mt-2">
        <a data-pjax="#repo-content-pjax-container" data-test-selector="commit-tease-commit-message" class="Link--primary text-bold" href="/bitcoinjs/bitcoinjs-lib/commit/24e4d6f6ec2b864b3b934ee36e7a9bcb406eb5f0">Merge pull request</a> <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1163217174" data-permission-text="Title is private" data-url="https://github.com/bitcoinjs/bitcoinjs-lib/issues/1779" data-hovercard-type="pull_request" data-hovercard-url="/bitcoinjs/bitcoinjs-lib/pull/1779/hovercard" href="https://github.com/bitcoinjs/bitcoinjs-lib/pull/1779">#1779</a> <a data-pjax="#repo-content-pjax-container" data-test-selector="commit-tease-commit-message" class="Link--primary text-bold" href="/bitcoinjs/bitcoinjs-lib/commit/24e4d6f6ec2b864b3b934ee36e7a9bcb406eb5f0">from Devils-Knight/permissions</a>
      </div>
      <pre class="mt-2 text-mono color-fg-muted text-small ws-pre-wrap">Add token permissions for main_ci.yml</pre>
    <div class="d-flex flex-items-center">
      <code class="border d-lg-none mt-2 px-1 rounded-2">24e4d6f</code>
    </div>
  </div>
      <div class="flex-shrink-0">
        <h2 class="sr-only">Git stats</h2>
        <ul class="list-style-none d-flex">
          <li class="ml-0 ml-md-3">
            <a data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/commits/master" class="pl-3 pr-3 py-3 p-md-0 mt-n3 mb-n3 mr-n3 m-md-0 Link--primary no-underline no-wrap">
              <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-history">
    <path fill-rule="evenodd" d="M1.643 3.143L.427 1.927A.25.25 0 000 2.104V5.75c0 .138.112.25.25.25h3.646a.25.25 0 00.177-.427L2.715 4.215a6.5 6.5 0 11-1.18 4.458.75.75 0 10-1.493.154 8.001 8.001 0 101.6-5.684zM7.75 4a.75.75 0 01.75.75v2.992l2.028.812a.75.75 0 01-.557 1.392l-2.5-1A.75.75 0 017 8.25v-3.5A.75.75 0 017.75 4z"></path>
</svg>
              <span class="d-none d-sm-inline">
                    <strong>2,901</strong>
                    <span aria-label="Commits on master" class="color-fg-muted d-none d-lg-inline">
                      commits
                    </span>
              </span>
            </a>
          </li>
        </ul>
      </div>
    </div>
  </div>
    <h2 id="files"  class="sr-only">Files</h2>



    <a class="d-none js-permalink-shortcut" data-hotkey="y" href="/bitcoinjs/bitcoinjs-lib/tree/24e4d6f6ec2b864b3b934ee36e7a9bcb406eb5f0">Permalink</a>

  <div data-view-component="true" class="include-fragment-error flash flash-error flash-full py-2">
  <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path>
</svg>

    Failed to load latest commit information.



</div>  <div class="js-details-container Details">
    <div role="grid" aria-labelledby="files" class="Details-content--hidden-not-important js-navigation-container js-active-navigation-container d-md-block" data-pjax>
      <div class="sr-only" role="row">
        <div role="columnheader">Type</div>
        <div role="columnheader">Name</div>
        <div role="columnheader" class="d-none d-md-block">Latest commit message</div>
        <div role="columnheader">Commit time</div>
      </div>

        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="Directory" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-directory hx_color-icon-directory">
    <path fill-rule="evenodd" d="M1.75 1A1.75 1.75 0 000 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0016 13.25v-8.5A1.75 1.75 0 0014.25 3h-6.5a.25.25 0 01-.2-.1l-.9-1.2c-.33-.44-.85-.7-1.4-.7h-3.5z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="This path skips through empty directories" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/tree/master/.github/workflows"><span class="color-fg-muted">.github/</span>workflows</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="Pin actions for CI" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/ee5b0a641351f08c76cca9bbc4de568b0ef726c2">Pin actions for CI</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2022-03-08T22:57:42Z" data-view-component="true" class="no-wrap">Mar 8, 2022</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="Directory" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-directory hx_color-icon-directory">
    <path fill-rule="evenodd" d="M1.75 1A1.75 1.75 0 000 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0016 13.25v-8.5A1.75 1.75 0 0014.25 3h-6.5a.25.25 0 01-.2-.1l-.9-1.2c-.33-.44-.85-.7-1.4-.7h-3.5z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="src" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/tree/master/src">src</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="Add warning to future segwit version address generation/parsing" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/93af5afe67dbc491e36bdfc8d48a00179093f7d1">Add warning to future segwit version address generation/parsing</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2021-11-26T23:35:19Z" data-view-component="true" class="no-wrap">Nov 26, 2021</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="Directory" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-directory hx_color-icon-directory">
    <path fill-rule="evenodd" d="M1.75 1A1.75 1.75 0 000 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0016 13.25v-8.5A1.75 1.75 0 0014.25 3h-6.5a.25.25 0 01-.2-.1l-.9-1.2c-.33-.44-.85-.7-1.4-.7h-3.5z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="test" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/tree/master/test">test</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="test: upgrade ecpair lib to version 2.0.1" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/2edfb992fa09761e09490b5efa27ba13a77de374">test: upgrade ecpair lib to version 2.0.1</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2021-12-17T11:27:35Z" data-view-component="true" class="no-wrap">Dec 17, 2021</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="Directory" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-directory hx_color-icon-directory">
    <path fill-rule="evenodd" d="M1.75 1A1.75 1.75 0 000 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0016 13.25v-8.5A1.75 1.75 0 0014.25 3h-6.5a.25.25 0 01-.2-.1l-.9-1.2c-.33-.44-.85-.7-1.4-.7h-3.5z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="ts_src" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/tree/master/ts_src">ts_src</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="Add warning to future segwit version address generation/parsing" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/93af5afe67dbc491e36bdfc8d48a00179093f7d1">Add warning to future segwit version address generation/parsing</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2021-11-26T23:35:19Z" data-view-component="true" class="no-wrap">Nov 26, 2021</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title=".gitignore" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/blob/master/.gitignore">.gitignore</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="Move tests to TypeScript (coverage is still JS based)" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/6c08a0be40a4d382f64b7385531407372a7e3b91">Move tests to TypeScript (coverage is still JS based)</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2019-09-10T22:25:47Z" data-view-component="true" class="no-wrap">Sep 10, 2019</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title=".npm-audit-whitelister.json" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/blob/master/.npm-audit-whitelister.json">.npm-audit-whitelister.json</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="Add npm audit CI job" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/79e65eeb39a89cfb85476ca45576cc2dd04adf44">Add npm audit CI job</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2021-02-05T05:16:17Z" data-view-component="true" class="no-wrap">Feb 5, 2021</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title=".prettierignore" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/blob/master/.prettierignore">.prettierignore</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="style: add prettier" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/c74ab67ccf23b3796b17808e765ff580685b31ef">style: add prettier</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2019-03-04T13:09:53Z" data-view-component="true" class="no-wrap">Mar 4, 2019</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title=".prettierrc.json" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/blob/master/.prettierrc.json">.prettierrc.json</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="style: add prettier" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/c74ab67ccf23b3796b17808e765ff580685b31ef">style: add prettier</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2019-03-04T13:09:53Z" data-view-component="true" class="no-wrap">Mar 4, 2019</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="CHANGELOG.md" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/blob/master/CHANGELOG.md">CHANGELOG.md</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="Add Taproot example" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/24e5cc061699cf66e63df7b371d4d1171646d529">Add Taproot example</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2021-11-12T03:39:56Z" data-view-component="true" class="no-wrap">Nov 12, 2021</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="CONTRIBUTING.md" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/blob/master/CONTRIBUTING.md">CONTRIBUTING.md</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="Add TypeScript section to CONTRIBUTING" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/64aa7bacc3fc237cf4c0cb62c336bdfd063d123c">Add TypeScript section to CONTRIBUTING</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2019-03-07T07:43:12Z" data-view-component="true" class="no-wrap">Mar 7, 2019</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="LICENSE" data-pjax="#repo-content-pjax-container" itemprop="license" href="/bitcoinjs/bitcoinjs-lib/blob/master/LICENSE">LICENSE</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="Update License" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/02398bee911df5463de2f20730ff5f239da92b84">Update License</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2020-01-06T07:58:59Z" data-view-component="true" class="no-wrap">Jan 6, 2020</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="README.md" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/blob/master/README.md">README.md</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="Add Taproot example" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/24e5cc061699cf66e63df7b371d4d1171646d529">Add Taproot example</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2021-11-12T03:39:56Z" data-view-component="true" class="no-wrap">Nov 12, 2021</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="package-lock.json" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/blob/master/package-lock.json">package-lock.json</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="test: upgrade ecpair lib to version 2.0.1" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/2edfb992fa09761e09490b5efa27ba13a77de374">test: upgrade ecpair lib to version 2.0.1</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2021-12-17T11:27:35Z" data-view-component="true" class="no-wrap">Dec 17, 2021</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="package.json" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/blob/master/package.json">package.json</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="test: upgrade ecpair lib to version 2.0.1" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/2edfb992fa09761e09490b5efa27ba13a77de374">test: upgrade ecpair lib to version 2.0.1</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2021-12-17T11:27:35Z" data-view-component="true" class="no-wrap">Dec 17, 2021</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="tsconfig.json" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/blob/master/tsconfig.json">tsconfig.json</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="Use ES2020, add dev dep for randombytes" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/b1ff3cee498f4b3576e8f74fdb2475f23ea3ba04">Use ES2020, add dev dep for randombytes</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2021-10-20T14:55:57Z" data-view-component="true" class="no-wrap">Oct 20, 2021</time-ago>
          </div>

        </div>
        <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item ">
          <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;">
              <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted">
    <path fill-rule="evenodd" d="M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z"></path>
</svg>
          </div>

          <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3">
            <span class="css-truncate css-truncate-target d-block width-fit"><a class="js-navigation-open Link--primary" title="tslint.json" data-pjax="#repo-content-pjax-container" href="/bitcoinjs/bitcoinjs-lib/blob/master/tslint.json">tslint.json</a></span>
          </div>

          <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" >
              <span class="css-truncate css-truncate-target d-block width-fit markdown-title">
                    <a data-pjax="true" title="Refactor: Remove all require statements, remove ECPair, remove tiny-secp256k1 dep" class="Link--secondary" href="/bitcoinjs/bitcoinjs-lib/commit/e5a77304fa5f39f521163f2f4a68377181bb0839">Refactor: Remove all require statements, remove ECPair, remove tiny-s…</a>
              </span>
          </div>

          <div role="gridcell" class="color-fg-muted text-right" style="width:100px;">
              <time-ago datetime="2021-10-20T10:18:01Z" data-view-component="true" class="no-wrap">Oct 20, 2021</time-ago>
          </div>

        </div>
    </div>
    <div class="Details-content--shown Box-footer d-md-none p-0">
      <button aria-expanded="false" type="button" data-view-component="true" class="js-details-target btn-link d-block width-full px-3 py-2">  View code
</button>    </div>
  </div>




</div>

    <readme-toc>

    <div id="readme" class="Box md js-code-block-container js-code-nav-container js-tagsearch-file Box--responsive"
        data-tagsearch-path="README.md"
        data-tagsearch-lang="Markdown">

      <div class="d-flex  js-sticky js-position-sticky top-0 border-top-0 border-bottom p-2 flex-items-center flex-justify-between color-bg-default rounded-top-2"  style="position: sticky; z-index: 30;" >
        <div class="d-flex flex-items-center">
            <details
  data-target="readme-toc.trigger"
  data-menu-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;trigger&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}"
  data-menu-hydro-click-hmac="0feae737603bcefe9c4d37c9c169fe3bc8d988b1dab76407fd4d88faab0598b0"
  class="dropdown details-reset details-overlay"
>
  <summary
    class="btn btn-octicon m-0 mr-2 p-2"
    aria-haspopup="true"
    aria-label="Table of Contents">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-list-unordered">
    <path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
</svg>
  </summary>


  <details-menu class="SelectMenu" role="menu">
    <div class="SelectMenu-modal rounded-3 mt-1" style="max-height:340px;">

        <div class="SelectMenu-filter">
          <input
            class="SelectMenu-input form-control js-filterable-field"
            id="toc-filter-field"
            type="text"
            autocomplete="off"
            spellcheck="false"
            autofocus
            placeholder="Filter headings"
            aria-label="Filter headings">
        </div>

      <div class="SelectMenu-list SelectMenu-list--borderless p-2" style="overscroll-behavior: contain;" data-filterable-for="toc-filter-field" data-filterable-type="substring">
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 text-emphasized" style="-webkit-box-orient: vertical; padding-left: 12px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#bitcoinjs-bitcoinjs-lib">BitcoinJS (bitcoinjs-lib)</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 24px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#should-i-use-this-in-production">Should I use this in production?</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 24px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#can-i-trust-this-code">Can I trust this code?</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 24px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#documentation">Documentation</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 24px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#installation">Installation</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 24px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#usage">Usage</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 36px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#browser">Browser</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 36px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#typescript-or-vscode-users">Typescript or VSCode users</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 24px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#examples">Examples</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 24px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#contributing">Contributing</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 36px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#running-the-test-suite">Running the test suite</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 24px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#complementing-libraries">Complementing Libraries</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 24px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#alternatives">Alternatives</a>
          <a role="menuitem" class="filter-item SelectMenu-item ws-normal wb-break-word line-clamp-2 py-1 " style="-webkit-box-orient: vertical; padding-left: 24px;" data-action="click:readme-toc#blur" data-targets="readme-toc.entries" data-hydro-click="{&quot;event_type&quot;:&quot;repository_toc_menu.click&quot;,&quot;payload&quot;:{&quot;target&quot;:&quot;entry&quot;,&quot;repository_id&quot;:1701968,&quot;originating_url&quot;:&quot;https://github.com/bitcoinjs/bitcoinjs-lib&quot;,&quot;user_id&quot;:null}}" data-hydro-click-hmac="6a381e987b8d90ff5af4e4f020ccc93cc46df79b9f295e0c1bd3c1cd9c7aaa70" href="#license-mit">LICENSE MIT</a>
      </div>
    </div>
  </details-menu>
</details>

          <h2 class="Box-title">
            <a href="#readme" data-view-component="true" class="Link--primary">README.md</a>
          </h2>
        </div>
      </div>

          <div class="Popover anim-scale-in js-tagsearch-popover"
     hidden
     data-tagsearch-url="/bitcoinjs/bitcoinjs-lib/find-definition"
     data-tagsearch-ref="master"
     data-tagsearch-code-nav-context="BLOB_VIEW">
  <div class="Popover-message Popover-message--large Popover-message--top-left TagsearchPopover mt-1 mb-4 mx-auto Box color-shadow-large">
    <div class="TagsearchPopover-content js-tagsearch-popover-content overflow-auto" style="will-change:transform;">
    </div>
  </div>
</div>

        <div data-target="readme-toc.content" class="Box-body px-5 pb-5">
          <article class="markdown-body entry-content container-lg" itemprop="text"><h1 dir="auto"><a id="user-content-bitcoinjs-bitcoinjs-lib" class="anchor" aria-hidden="true" href="#bitcoinjs-bitcoinjs-lib"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>BitcoinJS (bitcoinjs-lib)</h1>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/actions/workflows/main_ci.yml"><img src="https://github.com/bitcoinjs/bitcoinjs-lib/actions/workflows/main_ci.yml/badge.svg" alt="Github CI" style="max-width: 100%;"></a> <a href="https://www.npmjs.org/package/bitcoinjs-lib" rel="nofollow"><img src="https://camo.githubusercontent.com/a5e25a19dddff9496574a85e954663b6b9fbfe6d3d528e5fcd87dbc21be6b2e7/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f626974636f696e6a732d6c69622e737667" alt="NPM" data-canonical-src="https://img.shields.io/npm/v/bitcoinjs-lib.svg" style="max-width: 100%;"></a> <a href="https://github.com/prettier/prettier"><img src="https://camo.githubusercontent.com/c0486311910977832125780d8ef9ac681614939bd1b9328678007156a4648896/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64655f7374796c652d70726574746965722d6666363962342e7376673f7374796c653d666c61742d737175617265" alt="code style: prettier" data-canonical-src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square" style="max-width: 100%;"></a></p>
<p dir="auto">A javascript Bitcoin library for node.js and browsers. Written in TypeScript, but committing the JS files to verify.</p><p dir="auto">Released under the terms of the <a href="/bitcoinjs/bitcoinjs-lib/blob/master/LICENSE">MIT LICENSE</a>.</p>
<h2 dir="auto"><a id="user-content-should-i-use-this-in-production" class="anchor" aria-hidden="true" href="#should-i-use-this-in-production"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Should I use this in production?</h2>
<p dir="auto">If you are thinking of using the <em>master</em> branch of this library in production, <strong>stop</strong>.
Master is not stable; it is our development branch, and <a href="https://github.com/bitcoinjs/bitcoinjs-lib/tags">only tagged releases may be classified as stable</a>.</p>
<h2 dir="auto"><a id="user-content-can-i-trust-this-code" class="anchor" aria-hidden="true" href="#can-i-trust-this-code"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Can I trust this code?</h2>
<blockquote>
<p dir="auto">Don't trust. Verify.</p>
</blockquote>
<p dir="auto">We recommend every user of this library and the <a href="https://github.com/bitcoinjs">bitcoinjs</a> ecosystem audit and verify any underlying code for its validity and suitability,  including reviewing any and all of your project's dependencies.</p>
<p dir="auto">Mistakes and bugs happen, but with your help in resolving and reporting <a href="https://github.com/bitcoinjs/bitcoinjs-lib/issues">issues</a>, together we can produce open source software that is:</p>
<ul dir="auto">
<li>Easy to audit and verify,</li>
<li>Tested, with test coverage &gt;95%,</li>
<li>Advanced and feature rich,</li>
<li>Standardized, using <a href="https://github.com/prettier/prettier">prettier</a> and Node <code>Buffer</code>'s throughout, and</li>
<li>Friendly, with a strong and helpful community, ready to answer questions.</li>
</ul>
<h2 dir="auto"><a id="user-content-documentation" class="anchor" aria-hidden="true" href="#documentation"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Documentation</h2>
<p dir="auto">Presently,  we do not have any formal documentation other than our <a href="#examples">examples</a>, please <a href="https://github.com/bitcoinjs/bitcoinjs-lib/issues/new">ask for help</a> if our examples aren't enough to guide you.</p>
<p dir="auto">You can find a <a href="https://bitcoincore.tech/apps/bitcoinjs-ui/index.html" rel="nofollow">Web UI</a> that covers most of the <code>psbt.ts</code>, <code>transaction.ts</code> and <code>p2*.ts</code> APIs <a href="https://bitcoincore.tech/apps/bitcoinjs-ui/index.html" rel="nofollow">here</a>.</p>
<h2 dir="auto"><a id="user-content-installation" class="anchor" aria-hidden="true" href="#installation"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Installation</h2>
<div class="highlight highlight-source-shell position-relative overflow-auto" data-snippet-clipboard-copy-content="npm install bitcoinjs-lib
# optionally, install a key derivation library as well
npm install ecpair bip32
# ecpair is the ECPair class for single keys
# bip32 is for generating HD keys"><pre>npm install bitcoinjs-lib
<span class="pl-c"><span class="pl-c">#</span> optionally, install a key derivation library as well</span>
npm install ecpair bip32
<span class="pl-c"><span class="pl-c">#</span> ecpair is the ECPair class for single keys</span>
<span class="pl-c"><span class="pl-c">#</span> bip32 is for generating HD keys</span></pre></div>
<p dir="auto">Previous versions of the library included classes for key management (ECPair, HDNode(-&gt;"bip32")) but now these have been separated into different libraries. This lowers the bundle size significantly if you don't need to perform any crypto functions (converting private to public keys and deriving HD keys).</p>
<p dir="auto">Typically we support the <a href="https://github.com/nodejs/Release">Node Maintenance LTS version</a>. TypeScript target will be set
to the ECMAScript version in which all features are fully supported by current Active Node LTS.
However, depending on adoption among other environments (browsers etc.) we may keep the target back a year or two.
If in doubt, see the <a href="/bitcoinjs/bitcoinjs-lib/blob/master/.github/workflows/main_ci.yml">main_ci.yml</a> for what versions are used by our continuous integration tests.</p>
<p dir="auto"><strong>WARNING</strong>: We presently don't provide any tooling to verify that the release on <code>npm</code> matches GitHub.  As such, you should verify anything downloaded by <code>npm</code> against your own verified copy.</p>
<h2 dir="auto"><a id="user-content-usage" class="anchor" aria-hidden="true" href="#usage"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Usage</h2>
<p dir="auto">Crypto is hard.</p>
<p dir="auto">When working with private keys, the random number generator is fundamentally one of the most important parts of any software you write.
For random number generation, we <em>default</em> to the <a href="https://github.com/crypto-browserify/randombytes"><code>randombytes</code></a> module, which uses <a href="https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues" rel="nofollow"><code>window.crypto.getRandomValues</code></a> in the browser, or Node js' <a href="https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback" rel="nofollow"><code>crypto.randomBytes</code></a>, depending on your build system.
Although this default is ~OK, there is no simple way to detect if the underlying RNG provided is good enough, or if it is <strong>catastrophically bad</strong>.
You should always verify this yourself to your own standards.</p>
<p dir="auto">This library uses <a href="https://github.com/bitcoinjs/tiny-secp256k1">tiny-secp256k1</a>, which uses <a href="https://tools.ietf.org/html/rfc6979" rel="nofollow">RFC6979</a> to help prevent <code>k</code> re-use and exploitation.
Unfortunately, this isn't a silver bullet.
Often, Javascript itself is working against us by bypassing these counter-measures.</p>
<p dir="auto">Problems in <a href="https://github.com/feross/buffer"><code>Buffer (UInt8Array)</code></a>, for example, can trivially result in <strong>catastrophic fund loss</strong> without any warning.
It can do this through undermining your random number generation, accidentally producing a <a href="https://www.nilsschneider.net/2013/01/28/recovering-bitcoin-private-keys.html" rel="nofollow">duplicate <code>k</code> value</a>, sending Bitcoin to a malformed output script, or any of a million different ways.
Running tests in your target environment is important and a recommended step to verify continuously.</p>
<p dir="auto">Finally, <strong>adhere to best practice</strong>.
We are not an authorative source of best practice, but, at the very least:</p>
<ul dir="auto">
<li><a href="https://en.bitcoin.it/wiki/Address_reuse" rel="nofollow">Don't re-use addresses</a>.</li>
<li>Don't share BIP32 extended public keys ('xpubs'). <a href="https://bitcoin.stackexchange.com/questions/56916/derivation-of-parent-private-key-from-non-hardened-child" rel="nofollow">They are a liability</a>, and it only takes 1 misplaced private key (or a buggy implementation!) and you are vulnerable to <strong>catastrophic fund loss</strong>.</li>
<li><a href="https://security.stackexchange.com/questions/181580/why-is-math-random-not-designed-to-be-cryptographically-secure" rel="nofollow">Don't use <code>Math.random</code></a> - in any way - don't.</li>
<li>Enforce that users always verify (manually) a freshly-decoded human-readable version of their intended transaction before broadcast.</li>
<li><a href="https://en.bitcoin.it/wiki/Brainwallet#cite_note-1" rel="nofollow">Don't <em>ask</em> users to generate mnemonics</a>, or 'brain wallets',  humans are terrible random number generators.</li>
<li>Lastly, if you can, use <a href="https://www.typescriptlang.org/" rel="nofollow">Typescript</a> or similar.</li>
</ul>
<h3 dir="auto"><a id="user-content-browser" class="anchor" aria-hidden="true" href="#browser"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Browser</h3>
<p dir="auto">The recommended method of using <code>bitcoinjs-lib</code> in your browser is through <a href="https://github.com/substack/node-browserify">Browserify</a>.
If you're familiar with how to use browserify, ignore this and carry on, otherwise, it is recommended to read the tutorial at <a href="https://browserify.org/" rel="nofollow">https://browserify.org/</a>.</p>
<p dir="auto"><strong>NOTE</strong>: We use Node Maintenance LTS features, if you need strict ES5, use <a href="https://github.com/babel/babelify"><code>--transform babelify</code></a> in conjunction with your <code>browserify</code> step (using an <a href="https://babeljs.io/docs/plugins/preset-es2015/" rel="nofollow"><code>es2015</code></a> preset).</p>
<p dir="auto"><strong>WARNING</strong>: iOS devices have <a href="https://github.com/feross/buffer/issues/136">problems</a>, use at least <a href="https://github.com/feross/buffer/pull/155">buffer@5.0.5</a> or greater,  and enforce the test suites (for <code>Buffer</code>, and any other dependency) pass before use.</p>
<h3 dir="auto"><a id="user-content-typescript-or-vscode-users" class="anchor" aria-hidden="true" href="#typescript-or-vscode-users"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Typescript or VSCode users</h3>
<p dir="auto">Type declarations for Typescript are included in this library. Normal installation should include all the needed type information.</p>
<h2 dir="auto"><a id="user-content-examples" class="anchor" aria-hidden="true" href="#examples"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Examples</h2>
<p dir="auto">The below examples are implemented as integration tests, they should be very easy to understand.
Otherwise, pull requests are appreciated.
Some examples interact (via HTTPS) with a 3rd Party Blockchain Provider (3PBP).</p>
<ul dir="auto">
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/taproot.md">Taproot Key Spend</a></p>
</li>
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts">Generate a random address</a></p>
</li>
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts">Import an address via WIF</a></p>
</li>
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts">Generate a 2-of-3 P2SH multisig address</a></p>
</li>
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts">Generate a SegWit address</a></p>
</li>
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts">Generate a SegWit P2SH address</a></p>
</li>
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts">Generate a SegWit 3-of-4 multisig address</a></p>
</li>
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts">Generate a SegWit 2-of-2 P2SH multisig address</a></p>
</li>
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts">Support the retrieval of transactions for an address (3rd party blockchain)</a></p>
</li>
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts">Generate a Testnet address</a></p>
</li>
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts">Generate a Litecoin address</a></p>
</li>
<li>
<p dir="auto"><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/tes…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants