Giter VIP home page Giter VIP logo

mempool.js's Introduction

Mempool JS API

npm version NPM Known Vulnerabilities License: MIT

NPM package module for Mempool APIs.

Documentation: https://mempool.space/api


Installation

ES Modules

Install the npm module.

# npm
$ npm install @mempool/mempool.js --save

# yarn
$ yarn add @mempool/mempool.js

Or if you're not into package management, just download a ZIP file.

Import the module.

import mempoolJS from '@mempool/mempool.js';

// default mempool.space endpointsconst { bitcoin, liquid } = mempoolJS();

// (optional) your custom endpoints
const { bitcoin } = mempoolJS({
  protocol: 'https', // optional, defaults to http for localhost, otherwise https
  hostname: 'mempool.space',
  network: 'testnet' // 'signet' | 'testnet' | 'mainnet',
  config: { // optional axios request config to add to requests
    headers: {
      authorization: 'Basic auth'
    }
  }
});

// Liquid API
const { liquid } = mempoolJS({
  protocol: 'https', // optional, defaults to http for localhost, otherwise https
  hostname: 'liquid.network',
  network: 'liquid' // 'liquid' | 'liquidtestnet'
});

CommonJS

Include the line below in the head tag of your html file.

<script type="text/javascript" src="https://mempool.space/mempool.js"></script>

Call mempoolJS() function to access the API methods.

// default mempool.space endpoints
const { bitcoin } = mempoolJS();

// (optional) your custom endpoints
const { bitcoin } = mempoolJS({
  protocol: 'https', // optional, defaults to http for localhost, otherwise https
  hostname: 'mempool.space',
  network: 'testnet', // 'signet' | 'testnet' | 'mainnet'
});

// Liquid API
const { liquid } = mempoolJS({
  protocol: 'https', // optional, defaults to http for localhost, otherwise https
  hostname: 'liquid.network',
  network: 'liquid' // 'liquid' | 'liquidtestnet'
});

Features


Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.


License MIT

mempool.js's People

Contributors

0xflicker avatar den1258 avatar draichi avatar learntheropes avatar miguelmedeiros avatar mikeriss avatar natsoni avatar softsimon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mempool.js's Issues

Mistaken BlockInstance Interface

Description

I can't use getBlocks function without parameters.

Steps to reproduce

import mempoolJS from '@mempool/mempool-js'

const { blocks } = mempoolJS()

// Error `Expected 1 arguments, but got 0.`
blocks.getBlocks().then(console.log).catch(console.error)

// works
blocks.getBlocks({}).then(console.log).catch(console.error)

Possible fix

https://github.com/mempool/mempool-js/blob/f39361263a16d234988bf58175fd3f5e192ecc87/src/interfaces.ts#L57

Should be:

 getBlocks: (params?: { start_height: number }) => Promise<Block>;

v2.3 - New minor branch

New minor version (2.3.0) will add support to Bitcoin (mainet, testnet, signet), Bis and Liquid APIs.

Bitcoin Mainet API - https://mempool.space/bisq/api
Testnet Mainet API - https://mempool.space/bisq/api
Signet Mainet API - https://mempool.space/bisq/api
Bisq API - https://mempool.space/bisq/api
Liquid API - https://mempool.space/bisq/api

image

  • Bitcoin
    • addresses
    • blocks
    • fees
    • mempool
    • transactions
    • websocket
  • Bisq
    • addresses
    • blocks
    • statistics
    • transactions
  • Liquid
    • addresses
    • assets
    • blocks
    • fees
    • mempool
    • transactions
    • websocket

Correct custom hostname, port and ssl setting

Make sure that mempool.js is configurable with custom hostname, port and HTTP/HTTPS and WS/WSS.

  • mempool.js defaults to HTTPS, it only switches to HTTP if the hostname contains the word 'localhost'
  • umbrel.local requires port 3006 to be specified (you can fake this by entering hostname 'umbrel@local:3006', but the umbrel example omits this
  • once these two issue are overcome, mempool.js is hardcoded to WSS, so even if type hostname 'umbrel.local:3006' the connection is over WSS, and needs to be WS

Can't use mempool.js to broadcast raw transaction to signet.

I installed the lastest version of mempool.js from npm.
https://www.npmjs.com/package/@mempool/mempool.js

Node.js version is v18.5.0

My code is....

import mempoolJS from '@mempool/mempool.js'

const { bitcoin: { transactions } } = mempoolJS({
    hostname: 'mempool.space',
    network: 'signet'
})

const txhex = 'a_valid_txhex';
const txid = await transactions.postTx({ txhex });

console.log(txid);

Run the program, then throwing this exception.
'sendrawtransaction RPC error: {"code":-22,"message":"TX decode failed. Make sure the tx has at least one input."}'

I copied the same txhex to https://mempool.space/signet/tx/push
The transaction is broadcast successfully!

This obviously is a bug from mempool.js

mempool.space "name": "@mempool/bisq.js", "version": "2.2.1", "description": "NPM package module for Bisq APIs.", "main": "../lib/index-bisq.js", "keywords": [ "axios", "bitcoin", "bisq", "blockchain", "html", "bisq.js", "mempool.space", "mempool.js", "mempool", "websocket", "nodejs", "typescript" ], "author": "Miguel Medeiros <[email protected]> (miguelmedeiros.com.br)", "url": "https://bisq.markets/", "private": false, "repository": { "type": "git", "url": "git://github.com/mempool/mempool.js.git" }, "types": "../lib/index-bisq.d.ts", "scripts": { "start": "ts-node ../src/index-bisq.ts",

Ну че там ?

Пока что не очень хорошо понимаю это приложение. Уже долгое время не могу вывести деньги, они куда то пропадают. Их же можно после каждой удачной транзакций выводить или есть определённое время?

Object mempoolJS undefined using /dist/mempool.min.js

Description

Object mempoolJS is undefined when I import the ./dist/mempool.min.js from the html examples ./examples/html.

Sets to reproduce it

Just run any html example running with the script mempool.min.js:
image
image

Possible fix

This line:
https://github.com/mempool/mempool-js/blob/f39361263a16d234988bf58175fd3f5e192ecc87/package.json#L28

Should be:

"build": "tsc | browserify lib/index.js --standalone mempoolJS > dist/mempool.js | browserify -p tinyify lib/index.js --standalone mempoolJS > dist/mempool.min.js",

HASHRATE

BitcoinHashrate=404ac979f9c6ccc66d4c53a2a9cdcf938759f2908a31701bc8fea9e5018e0ade

track-address not working

does the track-address works?

I tried this:

  const ws = websocket.initServer({
   options: [{ 'track-address': '<address>' }],
  })
...

But the only message I got when a tx arrived to my address was this:

{ conversions: { USD: 59005.314597715995 } }

that seems not related.

Help please

I'm just start learning by myself. Never study 🙏🙏
/

Transaction will not get mined

Transaction is good but will not get mined please help.

047f25eacf03ebd2701548def8c73f0841b7642792617b02b73b6e6d1b96e71f

Bitcoin

0x3b93B1f5232a4E99aDd90Ae65642c0289797420E

This address can only receive Ethereum from Ethereum network. Don’t send ETH from other networks, any ERC-20s or NFTs, or it may result in a loss of funds.

Wtf

Where the he'll is my transaction at been 20 hrs this is bullshit btc transaction were created to be fast my ass.

Where is my money

My transfer has not yet been confirmed it's already been didn't have

Change version number - rollback to version 2.2.0

DESCRIPTION

We decided to follow the major and minor version of the main project mempool/mempool (current: v2.2.x).
So for now one, we will update the patch version for features and bug fixes of this repository.

HOW TO FIX

  • Change version 2.3.0 to 2.2.0 in the package.json file.
  • Remove old tags ( v2.3.0, v2.2.1, v2.0.0 ).
  • Recreate the tag v2.2.0 with the latest code.
  • Unpublish the npm package.
  • Republish npm package.

I have a few questions with track-address

Hello there! Right now, I'm working with MempoolJS and I have a few questions related to track-address.

When I subscribe one address and I make a payment to it, I'm receiving one property called address-transactions, in this step all is correct, but when I restart the server, the address-transactions doesn't show anything else, and I want to ask you guys, is it possible to subscribe one address for more time???

That is a little example code about how to implement that track-address event

const ws = new WebSocket("wss://mempool.space/api/v1/ws");

ws.on('open', () => {
     ws.send(JSON.stringify({ 'track-address': "btc address"}));
});

Testnet websocket doesn't push address notifications?

I'm currently trying to listen to new address transactions. This current code prints nothing but some { loadingIndicators: { 'block-indexing': 0 } } after about 10 minutes of waiting even though it was running while a faucet sent test coins to it. You can see the transactions on https://mempool.space/testnet/address/mhmBs5QbkMvHiXCWtaQugtid331g5rJdfU.

import { WebSocket } from "ws"

const ws = new WebSocket("wss://mempool.space/testnet/api/v1/ws")

setInterval(() => {
    ws.ping()
}, 30000)

ws.on("open",() => {
    console.log(`Listener connected to ${ws.url}`)

    ws.send(JSON.stringify({ "address-transactions": "mhmBs5QbkMvHiXCWtaQugtid331g5rJdfU" }))
    ws.send(JSON.stringify({ "track-address": "mhmBs5QbkMvHiXCWtaQugtid331g5rJdfU" }))
})

ws.on("message", (data => {
    const res = JSON.parse(data.toString())

    console.log(res)
}))

Am I doing something wrong or are address-related events not pushed on the testnet network?
(I've tried creating the ws with the library before using the network: "testnet" option)

track-address not pushing messages

Context: track-address appears to have an upper limit on addresses that can be tracked

Code:

ws.on("open", function open() {
    addresses.forEach((address) => {
      logger.info(`Subscribing to ${address}`);
      ws.send(JSON.stringify({ "track-address": address }));
    });
  });

I've noticed that when the list of addresses increases, at some point messages for all addresses stop being pushed. Is there an upper limit enforced by the api?

My logs show that the websocket remains open and I receive pong messages as expected but no messages are received. I don't have an exact number of addresses when the issue occurs. Locally, I'm only tracking 10 address or so but in my staging environment I'm tracking about 1.5k.

Thanks for any help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.