7.1.0 • Published 13 days ago

@bitaccess/coinlib v7.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
13 days ago

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 xrpPayments = coinPayments.forNetwork('XRP')
await xrpPayments.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 } = xrpPayments.getPayport(1234)
// Customer sends deposit to `address` with destination tag `extraId`

Validate an address:

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

Get the balance of an address:

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

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

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

Generate a simple send transaction

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

Get a transaction and check if it is confirmed:

let txInfo = await xrpPayments.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

7.1.0

13 days ago

7.0.9

6 months ago

7.0.8

1 year ago

7.0.7

2 years ago

7.0.6

2 years ago

7.0.4

2 years ago

7.0.3

2 years ago

7.0.2

2 years ago

7.0.5

2 years ago

6.1.0

2 years ago

6.0.1

2 years ago

6.0.0

2 years ago

6.0.3

2 years ago

6.0.2

2 years ago

6.0.5

2 years ago

6.0.4

2 years ago

7.0.0

2 years ago

7.0.1

2 years ago

5.2.1

2 years ago

5.1.2

3 years ago

5.2.0

3 years ago

5.0.5

3 years ago

5.1.1

3 years ago

5.1.0

3 years ago

5.0.4

3 years ago

5.0.3

3 years ago

5.0.2

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago