# bitcoin-live-transactions

> Get all bitcoin transactions real time over socket.io from insight servers online

Latest version **0.0.13** (published 2017-02-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install bitcoin-live-transactions
pnpm add bitcoin-live-transactions
yarn add bitcoin-live-transactions
bun add bitcoin-live-transactions
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.13 |
| Published | 2017-02-20 |
| First published | 2017-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Carlos Guerrero |
| Maintainers | guerrerocarlos |
| Keywords | bitcoin, live, transactions |

## Links

- npm: https://www.npmjs.com/package/bitcoin-live-transactions
- Repository: https://github.com/guerrerocarlos/bitcoin-live-transactions
- Homepage: https://github.com/guerrerocarlos/bitcoin-live-transactions#readme
- Issues: https://github.com/guerrerocarlos/bitcoin-live-transactions/issues
- npm.io page: https://npm.io/package/bitcoin-live-transactions

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^2.6.1
- [request](https://npm.io/package/request.md) ^2.79.0
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^1.7.3

## Recent versions

- 0.0.13 (latest) — 2017-02-20
- 0.0.12 — 2017-02-19
- 0.0.11 — 2017-02-19
- 0.0.10 — 2017-02-19
- 0.0.9 — 2017-02-19
- 0.0.7 — 2017-02-19
- 0.0.6 — 2017-02-19
- 0.0.5 — 2017-02-19
- 0.0.3 — 2017-02-19
- 0.0.2 — 2017-02-19
- 0.0.1 — 2017-02-19

## README

bitcoin-live-transactions
=====

This module uses running [insight-api](https://github.com/bitpay/insight-api) instances to get live bitcoin transaction as they happen in the Bitcoin P2P network. 

How to use it
--

Create a **BLT** (Bitcoin Live Transactions) instance:
```javascript
var BLT = require("bitcoin-live-transactions")
var bitcoin = new BLT()
```

Connect to the Bitcoin P2P network:
```javasctript
bitcoin.connect()
```

Get a notification when successfully connected to the  Bitcoin P2P network.
```javascript
bitcoin.events.on('connected', function() {
   // start listening to addresses
})
```

Check an address
--
Check uBTC balance for a given bitcoin address:
```javascript
bitcoin.getBalance('1CZGSZPGsyeeLYyoXdmJtanEmaKKpwYM7g').then(function(balance) {
  console.log('balance:', balance);
})
```

Will output:

```javascript 
balance: {
  "address": "1BkJgdopq35eaZGRrau4wdnZFZ3qfM4DUb",
  "in": 3018.02,
  "out": 3018.02,
  "curr": "bits(uBTC)",
  "balance": 0,
  "txs": 2
}
```

That can be checked here:
[https://insight.bitpay.com/address/1CZGSZPGsyeeLYyoXdmJtanEmaKKpwYM7g](https://insight.bitpay.com/address/1CZGSZPGsyeeLYyoXdmJtanEmaKKpwYM7g)

To get all the detailed information about an address, use **bitcoin.getTxs** instead of **bitcoin.getBalance**

Live stream
--

To Listen to live transaction events on the Bitcoin P2P network for a given address, the event is called as the address itself:
```javascript
bitcoin.events.on('138WJKb1mXbkRGNpyMVEZ9EsoXjMEvJfT4',function(tx){
  console.log('Transaction detected!', tx);
})
```
Will trigger the event in real time if a payment is done to that address:
```javascript
Transaction detected! { address: '138WJKb1mXbkRGNpyMVEZ9EsoXjMEvJfT4',
  amount: 381000 }
```

Show everything live
--

If you want to see **ALL** transactions happening live, use the **tx** event:



```javascript
bitcoin.events.on('tx',function(tx){
  console.log('>> Transaction detected:', tx);
})
```
Will trigger the event in real time if a payment is done to that address:
```javascript
>> Transaction detected: { txid: '82d1ce35c4b755f8365bcfab9c485cf798cfcfe6e62a222995ca28335ada5374',
  valueOut: 0.01068895,
  vout:
   [ { '1P4BHe6R9Wa5cRWAPPT7FCzCDoBEqC6VK6': 1047784 },
     { '1Jp1tW7FFS3kS3jXgWbppiYn6oR9d4ckec': 21111 } ],
  isRBF: false }
>> Transaction detected: { txid: '6ed5f489e080dbc07ed7a6cc18c70271443708aa57a032deb1b1bf3ed38a06cd',
  valueOut: 0.22005829,
  vout:
   [ { '1LxJtK99ryA1yRjekQeU1ChZdsBoNeWQgp': 8810932 },
     { '1Q63dyZEwQAtn8dsxyvK1dduG4axxjBgm9': 13194897 } ],
  isRBF: false }
...
```

---
_Source: https://npm.io/package/bitcoin-live-transactions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
