Socket
Book a DemoInstallSign in
Socket

@bitaccess/coinlib

Package Overview
Dependencies
Maintainers
37
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitaccess/coinlib

Library to assist in processing cryptocurrency payments, such as deriving addresses and sweeping funds

9.0.0
latest
Source
npmnpm
Version published
Weekly downloads
9
-47.06%
Maintainers
37
Weekly downloads
 
Created
Source

coinlib

Library to assist in processing cryptocurrency payments.

Getting Started

npm i @bitaccess/coinlib
import { CoinPayments } from '@bitaccess/coinlib'

const coinPayments = new CoinPayments({
  seed: '5cf2d4a8b0...ca676651f'
})

To begin processing payments, select your asset

const btcPayments = coinPayments.forNetwork('BTC')
await btcPayments.init()

Generate a deposit address. This is useful if you are a hot wallet and don't store the private key. You will need to keep track of which path node you are on (increasing int):

let { address, extraId } = btcPayments.getPayport(1234)
// Customer sends deposit to `address` with destination tag `extraId`

Validate an address:

if (btcPayments.isValidAddress(depositAddress)) {
  // do something
}

Get the balance of an address:

let { confirmedBalance, unconfirmedBalance } = await btcPayments.getBalance(1234)

Generate a sweep transaction for an address, then broadcast it:

let unsignedTx = await btcPayments.createSweepTransaction(1234, to)
let signedTx = await btcPayments.signTransaction(unsignedTx)
let { id: txHash } = await btcPayments.broadcastTransaction(signedtx)

Generate a simple send transaction

let unsignedTx = await btcPayments.createTransaction(1234, to, '1.234')
// Then sign and broadcast the transaction

Get a transaction and check if it is confirmed:

let txInfo = await btcPayments.getTransactionInfo(txHash)
if (txInfo.isConfirmed) {
  // txInfo.confirmations > 0
}

In some circumstances, you may want a read-only copy that can do everything but sign. First create it with your seed as usual, then get the public config to use for read only version.

const readOnlyConfig = coinPayments.getPublicConfig()
const readOnlyCoinPayments = new CoinPayments(readOnlyConfig)

See tests or types for more utilities

License

MIT

Keywords

coin

FAQs

Package last updated on 18 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.