elements-network-encoding

Compact encodings for elements network data types

Usage no npm install needed!

<script type="module">
  import elementsNetworkEncoding from 'https://cdn.skypack.dev/elements-network-encoding';
</script>

README

elements-network-encoding

Compact encodings for ELements network data types. See compact-encoding docs for more detail.

Usage

const c = require('compact-encoding')
const { block, tx, outpoint } = require('elements-network-encoding')

const enc = c.encode(block, someBlock)

API

tx

Encodes the following information, titles in square brackets are optional fields. Matches the return value of getrawtransaction rpc call (with verbosity = 1).

{
  in_active_chain,
  txid,
  [wtxid],
  [withash],
  hash,
  size,
  vsize,
  weight,
  version,
  locktime,
  vin : [
    {
      coinbase,
      [txid],
      [vout],
      [scriptSig]: {
        hex,
      },
      sequence,
      [txinwitness],
    }
  ],
  vout : [
    {
      value,
      n,
      scriptPubKey : {
        hex,
        [reqSigs],
        type,
        [addresses],
        [pegout_chain],
        [pegout_hex],
        [pegout_type],
        [pegout_addresses],
      }
    }
  ],
  [blockhash],
  confirmations,
  blocktime,
  time,
}

block

Encodes the following information, titles in square brackets are optional fields. Matches the return value of getblock rpc call (with verbosity = 1).

{
  hash,
  confirmations,
  size,
  weight,
  height,
  version,
  versionHex,
  [merkleRoot],
  tx: [ txid ],
  time,
  mediantime,
  [nonce],
  [bits],
  [chainwork],
  nTx,
  [signblock_witness_hex],
  dynamic_parameters : {
    current : {
      signblockscript,
      max_block_witness,
      fedpegscript,
      extension_space,
    },
    proposed : {
      signblockscript,
      max_block_witness,
      fedpegscript,
      extension_space,
    }
  },
  previousblockhash,
  [nextblockhash]
})

block.verbose

Encodes the same information as above, except tx, is encoded as tx structs rather than a list of txids. Matches the return value of getblock rpc call (with verbosity = 2).

outpoint

Encodes an array of { txid, vout } tuples

[
  {
    txid,
    vout
  }
]