1.0.0 • Published 4 years ago

txutils v1.0.0

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

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
1.0.0

4 years ago