npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

blockchain-payments-node

v1.4.0

Published

Blockahain.info Payments wrapper for Node.js

Downloads

14

Readme

Blockchain Payments API for Node.js

A simple wrapper over Blockchain.com's Payments API. Create and receive Bitcoin addresses and payment notification webhooks in seconds!

Downloads Version Node Version

Installation

npm install blockchain-payments-node

Prerequisites

  • A Blockchain.com API Key (request one here).
  • A Bitcoin wallet where you have access to its xPub key.
    • You can grab one from your existing wallet if it has support for it. See this article for instructions for the more popular wallets out there.
    • You can also obtain it directly from Blockchain.com by visiting your wallet settings. (Settings -> Addresses -> Manage -> More Options -> Show xPub)

Usage

Setup

New up an instance of the Blockchain API wrapper.

import BlockchainPayments from 'blockchain-payments-node';

const Blockchain = new BlockchainPayments({
    xpub: 'xpub6DQC9f...',        // See above for instructions on creating one
    apiKey: '5b1ae17...',         // Your blockchain.com API key
    webhookSecret: 'supersecret', // A secret code of your choice to validate incoming webhooks
})

Create payment address

Simply supply a webhook URI to be notified on. Once a payment is received for the returned address, you'll promptly receive an HTTP request on the specified URL.

Blockchain.createAddress({
    webhookUrl: 'https://example.com/ipn/btc' // URL to receive payment notification requests on.
})

Watch any Bitcoin address for payments

Blockchain's API isn't limited to just watching addresses you've created. You can watch any Bitcoin address for incoming and/or outgoing payments.

Blockchain.watchAddress({
    address: '3HoDXkm5iY...',                  // Bitcoin address to watch.
    webhookUrl: 'https://example.com/ipn/btc', // URL to receive payment notification requests on.

    // Optional parameters:
    confirmations: 1,       // Number of confirmations to wait for before a notification is sent to your webhook URL. (default: 1)
    onNotification: 'KEEP', // (DELETE, KEEP) Whether to keep sending webhooks to the specified URL once requested confirmations has been reached. (Default: 'Keep')
    type: 'ALL'             // (ALL, RECEIVE, SPEND) The type of action to receive notifications for. (default: 'ALL') Useful if you only want to track incoming payments.
})

Stop watching an address

Use the ID returned from the watchAddress() method to stop watching the address.

const watcher = await Blockchain.watchAddress({
    address: '3HoDXkm5iY...',
    webhookUrl: 'https://example.com/ipn/btc',
});

await Blockchain.stopWatch(watcher.id); // { deleted: true/false }

Notes

While this wrapper takes care of most for you, it is still encouraged that you go over the API docs as there are some caveats with address generation. Particularly in instances where one creates more than 20 unused addresses - this will result in an error until one of the 20 addresses receive at least one transaction.

License

This repository is licensed under the ISC license.

Copyright (c) 2019, Jørgen Vatle.