Miss any of our Open RFC calls?Watch the recordings here! »

txutils

1.0.0 • Public • Published

Tx utils

Utility helpers for working with transactions on bsv network (testnet or mainnet)

const priv = new bsv.PrivateKey('....', 'testnet')
const txutils = require('txutils')
const utils = new txutils(/* network 'main' or 'test' defaults to 'main' */)
// ---
const utxos = await utils.getUtxos(priv)
const tx = utils.buildFundsTx({ utxos, priv, address: 'dest', sats: 1000, feeb: 1 })
const res = await utils.dispatch(tx)
console.log(res)
  • dispatch (tx) broadcasts transaction
  • getScriptPubKey (pubkey) returns scriptPubKey from public key
  • getUtxos (priv) returns utxos for a private key
  • splitUtxos (priv, maxUtxo, minSats) splits utxos evenly between maxUtxo count and minSats per utxo
  • buildFundsTx ({utxos, priv, address, sats, feeb}) builds standard pay transaction
  • buildMetanetTx ({ priv, parentTx, subprotocol, metadata, data }) build metanet transaction
  • reserveUtxos (utxos, limit) remove utxos from an array until they fill a certain ammount of funds
  • getTxUtxos (tx) returns tx outputs in utxo format
  • recycleUtxos (tx, address, utxoArray) extracts utxos from tx to address and inserts into utxoArray
  • minigun (priv, limit) dispatch chained transactions from private key
  • shotgun (priv, rounds) dispatch multi chained transactions for each utxo of priv

Install

npm i txutils

DownloadsWeekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

10.4 kB

Total Files

4

Last publish

Collaborators

  • avatar