@veriblock/nodecore-parser
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

ATV/VTB parser

Interpreter

BTC scriptSig interpreter

const scriptSig = Buffer.from(...);
// accepts instance of Buffer or hex string
// throws if scriptSig is invalid (can not be parsed)
const publications = parseBtcScriptSig(scriptSig);

console.log(publications.atv);  // one ATV
console.log(publications.vtbs); // array of VTBs

ATV - AltPublication

const bytes = Buffer.from(...); 
const stream = new ReadStream(bytes);
const atv = ATV.read(stream);

Input:

01580101166772F51AB208D32771AB1506970EEB664462730B838E0203E800010701370100010C6865616465722062797465730112636F6E7465787420696E666F20627974657301117061796F757420696E666F2062797465734630440220398B74708DC8F8AEE68FCE0C47B8959E6FCE6354665DA3ED87A83F708E62AA6B02202E6C00C00487763C55E92C7B8E1DD538B7375D8DF2B2117E75ACBB9DB7DEB3C7583056301006072A8648CE3D020106052B8104000A03420004DE4EE8300C3CD99E913536CF53C4ADD179F048F8FE90E5ADF3ED19668DD1DBF6C2D8E692B1D36EAC7187950620A28838DA60A8C9DD60190C14C59B82CB90319E04000000010400000000201FEC8AA4983D69395010E4D18CD8B943749D5B4F575E88A375DEBDC5ED22531C040000000220000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040000013880002449C60619294546AD825AF03B0935637860679DDD55EE4FD21082E18686E26BBFDA7D5E4462EF24AE02D67E47D785C9B90F301010000000000010100

Output:

{
  "transaction": {
    "type": 1,
    "sourceAddress": "V5Ujv72h4jEBcKnALGc4fKqs6CDAPX",
    "sourceAmount": "1000",
    "outputs": [],
    "signatureIndex": "7",
    "publicationData": {
      "identifier": "0",
      "header": "686561646572206279746573",
      "payoutInfo": "7061796f757420696e666f206279746573",
      "contextInfo": "636f6e7465787420696e666f206279746573"
    },
    "signature": "30440220398b74708dc8f8aee68fce0c47b8959e6fce6354665da3ed87a83f708e62aa6b02202e6c00c00487763c55e92c7b8e1dd538b7375d8df2b2117e75acbb9db7deb3c7",
    "publicKey": "3056301006072a8648ce3d020106052b8104000a03420004de4ee8300c3cd99e913536cf53c4add179f048f8fe90e5adf3ed19668dd1dbf6c2d8e692b1d36eac7187950620a28838da60a8c9dd60190c14c59b82cb90319e"
  },
  "merklePath": {
    "treeIndex": 1,
    "layers": [
      "0000000000000000000000000000000000000000000000000000000000000000",
      "0000000000000000000000000000000000000000000000000000000000000000"
    ],
    "subject": "1fec8aa4983d69395010e4d18cd8b943749d5b4f575e88a375debdc5ed22531c",
    "index": 0
  },
  "containingBlock": {
    "height": 5000,
    "version": 2,
    "previousBlock": "449c60619294546ad825af03",
    "previousKeystone": "b0935637860679ddd5",
    "secondPreviousKeystone": "5ee4fd21082e18686e",
    "merkleRoot": "26bbfda7d5e4462ef24ae02d67e47d78",
    "timestamp": 1553699059,
    "difficulty": 16842752,
    "nonce": 1
  },
  "context": []
}

VTB - VeriBlockPublication

const bytes = Buffer.from(...); 
const stream = new ReadStream(bytes);
const vtb = VTB.read(stream);

Input:

02046002011667FF0A897E5D512A0B6DA2F41C479867FE6B3A4CAE2640000013350002A793C872D6F6460E90BED62342BB968195F8C515D3EED7277A09EFAC4BE99F95F0A15628B06BA3B44C0190B5C0495C9B8ACD0701C5235EBBBE9C02011B01000000010CE74F1FB694A001EEBB1D7D08CE6208033F5BF7263EBAD2DE07BBF518672732000000006A47304402200CF4998ABA1682ABEB777E762807A9DD2635A0B77773F66491B83EE3C87099BA022033B7CA24DC520915B8B0200CBDCF95BA6AE866354585AF9C53EE86F27362EBEC012103E5BAF0709C395A82EF0BD63BC8847564AC201D69A8E6BF448D87AA53A1C431AAFFFFFFFF02B7270D00000000001976A9148B9EA8545059F3A922457AFD14DDF3855D8B109988AC0000000000000000536A4C50000013350002A793C872D6F6460E90BED62342BB968195F8C515D3EED7277A09EFAC4BE99F95F0A15628B06BA3B44C0190B5C0495C9B8ACD0701C5235EBBBE9CD4E943EFE1864DF04216615CF92083F40000000002019F040000067B040000000C040000000400000020204D66077FDF24246FFD6B6979DFEDEF5D46588654ADDEB35EDB11E993C131F61220023D1ABE8758C6F917EC0C65674BBD43D66EE14DC667B3117DFC44690C6F5AF120096DDBA03CA952AF133FB06307C24171E53BF50AB76F1EDEABDE5E99F78D4EAD202F32CF1BEE50349D56FC1943AF84F2D2ABDA520F64DC4DB37B2F3DB20B0ECB572093E70120F1B539D0C1495B368061129F30D35F9E436F32D69967AE86031A275620F554378A116E2142F9F6315A38B19BD8A1B2E6DC31201F2D37A058F03C39C06C200824705685CECA003C95140434EE9D8BBBF4474B83FD4ECC2766137DB9A44D7420B7B9E52F3EE8CE4FBB8BE7D6CF66D33A20293F806C69385136662A74453FB162201732C9A35E80D4796BABEA76AACE50B49F6079EA3E349F026B4491CFE720AD17202D9B57E92AB51FE28A587050FD82ABB30ABD699A5CE8B54E7CD49B2A827BCB9920DCBA229ACDC6B7F028BA756FD5ABBFEBD31B4227CD4137D728EC5EA56C457618202CF1439A6DBCC1A35E96574BDDBF2C5DB9174AF5AD0D278FE92E06E4AC349A42500000C020134F09D43659EB53982D9AFB444B96FA4BB58C037D2914000000000000000000CE0B1A9A77DD0DB127B5DF4BC368CD6AC299A9747D991EC2DACBC0B699A2E4A5B3919B5C6C1F2C1773703BC001035000008020FC61CC9D4EAC4B2D14761A4D06AF8A9EF073DCD7FB5E0D000000000000000000A31508D4B101D0AD11E43EF9419C23FC277F67EDAE83C598EE70866DBCEF5E25268B9B5C6C1F2C17E11874AF50000040203F8E3980304439D853C302F6E496285E110E251251531300000000000000000039A72C22268381BD8D9DCFE002F472634A24CF0454DE8B50F89E10891E5FFB1DE08D9B5C6C1F2C1744290A925000000020BAA42E40345A7F826A31D37DB1A5D64B67B72732477422000000000000000000A33AD6BE0634647B26633AB85FA8DE258480BBB25E59C68E48BB0B608B12362B10919B5C6C1F2C1749C4D1F0473045022100F4DCE45EDCC6BFC4A1F44EF04E47E90A348EFD471F742F18B882AC77A8D0E89E0220617CF7C4A22211991687B17126C1BB007A3B2A25C550F75D66B857A8FD9D75E7583056301006072A8648CE3D020106052B8104000A03420004B3C10470C8E8E426F1937758D9FB5E97A1891176CB37D4C12D4AF4107B1AA3E8A8A754C06A22760E44C60642FBA883967C19740D5231336326F7962750C8DF990400000000040000000D202A014E88ED7AB65CDFAA85DAEAB07EEA6CBA5E147F736EDD8D02C2F9DDF0DEC60400000006205B977EA09A554AD56957F662284044E7D37450DDADF7DB3647712F59693997872020D0A3D873EEEEE6A222A75316DCE60B53CA43EAEA09D27F0ECE897303A53AE920C06FE913DCA5DC2736563B80834D69E6DFDF1B1E92383EA62791E410421B6C1120049F68D350EEB8B3DF630C8308B5C8C2BA4CD6210868395B084AF84D19FF0E902000000000000000000000000000000000000000000000000000000000000000002036252DFC621DE420FB083AD9D8767CBA627EDDEEC64E421E9576CEE21297DD0A40000013700002449C60619294546AD825AF03B0935637860679DDD55EE4FD21082E18686EB53C1F4E259E6A0DF23721A0B3B4B7AB5C9B9211070211CAF01C3F010100

Output:

{
  "transaction": {
    "address": "VE6MJFzmGdYdrxC8o6UCovVv7BdhdX",
    "publishedBlock": {
      "height": 4917,
      "version": 2,
      "previousBlock": "a793c872d6f6460e90bed623",
      "previousKeystone": "42bb968195f8c515d3",
      "secondPreviousKeystone": "eed7277a09efac4be9",
      "merkleRoot": "9f95f0a15628b06ba3b44c0190b5c049",
      "timestamp": 1553697485,
      "difficulty": 117556515,
      "nonce": 1589362332
    },
    "bitcoinTransaction": "01000000010ce74f1fb694a001eebb1d7d08ce6208033f5bf7263ebad2de07bbf518672732000000006a47304402200cf4998aba1682abeb777e762807a9dd2635a0b77773f66491b83ee3c87099ba022033b7ca24dc520915b8b0200cbdcf95ba6ae866354585af9c53ee86f27362ebec012103e5baf0709c395a82ef0bd63bc8847564ac201d69a8e6bf448d87aa53a1c431aaffffffff02b7270d00000000001976a9148b9ea8545059f3a922457afd14ddf3855d8b109988ac0000000000000000536a4c50000013350002a793c872d6f6460e90bed62342bb968195f8c515d3eed7277a09efac4be99f95f0a15628b06ba3b44c0190b5c0495c9b8acd0701c5235ebbbe9cd4e943efe1864df04216615cf92083f400000000",
    "merklePath": {
      "layers": [
        "4d66077fdf24246ffd6b6979dfedef5d46588654addeb35edb11e993c131f612",
        "023d1abe8758c6f917ec0c65674bbd43d66ee14dc667b3117dfc44690c6f5af1",
        "096ddba03ca952af133fb06307c24171e53bf50ab76f1edeabde5e99f78d4ead",
        "2f32cf1bee50349d56fc1943af84f2d2abda520f64dc4db37b2f3db20b0ecb57",
        "93e70120f1b539d0c1495b368061129f30d35f9e436f32d69967ae86031a2756",
        "f554378a116e2142f9f6315a38b19bd8a1b2e6dc31201f2d37a058f03c39c06c",
        "0824705685ceca003c95140434ee9d8bbbf4474b83fd4ecc2766137db9a44d74",
        "b7b9e52f3ee8ce4fbb8be7d6cf66d33a20293f806c69385136662a74453fb162",
        "1732c9a35e80d4796babea76aace50b49f6079ea3e349f026b4491cfe720ad17",
        "2d9b57e92ab51fe28a587050fd82abb30abd699a5ce8b54e7cd49b2a827bcb99",
        "dcba229acdc6b7f028ba756fd5abbfebd31b4227cd4137d728ec5ea56c457618",
        "2cf1439a6dbcc1a35e96574bddbf2c5db9174af5ad0d278fe92e06e4ac349a42"
      ],
      "subject": "94e097b110ba3adbb7b6c4c599d31d675de7be6e722407410c08ef352be585f1",
      "index": 1659
    },
    "blockOfProof": {
      "version": 549453824,
      "previousBlock": "134f09d43659eb53982d9afb444b96fa4bb58c037d2914000000000000000000",
      "merkleRoot": "ce0b1a9a77dd0db127b5df4bc368cd6ac299a9747d991ec2dacbc0b699a2e4a5",
      "timestamp": 1553699251,
      "bits": 388767596,
      "nonce": -1069846413
    },
    "blockOfProofContext": [
      {
        "version": 545259520,
        "previousBlock": "fc61cc9d4eac4b2d14761a4d06af8a9ef073dcd7fb5e0d000000000000000000",
        "merkleRoot": "a31508d4b101d0ad11e43ef9419c23fc277f67edae83c598ee70866dbcef5e25",
        "timestamp": 1553697574,
        "bits": 388767596,
        "nonce": -1351345951
      },
      {
        "version": 541065216,
        "previousBlock": "3f8e3980304439d853c302f6e496285e110e2512515313000000000000000000",
        "merkleRoot": "39a72c22268381bd8d9dcfe002f472634a24cf0454de8b50f89e10891e5ffb1d",
        "timestamp": 1553698272,
        "bits": 388767596,
        "nonce": -1844827836
      },
      {
        "version": 536870912,
        "previousBlock": "baa42e40345a7f826a31d37db1a5d64b67b72732477422000000000000000000",
        "merkleRoot": "a33ad6be0634647b26633ab85fa8de258480bbb25e59c68e48bb0b608b12362b",
        "timestamp": 1553699088,
        "bits": 388767596,
        "nonce": -254688183
      }
    ],
    "signature": "3045022100f4dce45edcc6bfc4a1f44ef04e47e90a348efd471f742f18b882ac77a8d0e89e0220617cf7c4a22211991687b17126c1bb007a3b2a25c550f75d66b857a8fd9d75e7",
    "publicKey": "3056301006072a8648ce3d020106052b8104000a03420004b3c10470c8e8e426f1937758d9fb5e97a1891176cb37d4c12d4af4107b1aa3e8a8a754c06a22760e44c60642fba883967c19740d5231336326f7962750c8df99"
  },
  "merklePath": {
    "treeIndex": 0,
    "layers": [
      "5b977ea09a554ad56957f662284044e7d37450ddadf7db3647712f5969399787",
      "20d0a3d873eeeee6a222a75316dce60b53ca43eaea09d27f0ece897303a53ae9",
      "c06fe913dca5dc2736563b80834d69e6dfdf1b1e92383ea62791e410421b6c11",
      "049f68d350eeb8b3df630c8308b5c8c2ba4cd6210868395b084af84d19ff0e90",
      "0000000000000000000000000000000000000000000000000000000000000000",
      "36252dfc621de420fb083ad9d8767cba627eddeec64e421e9576cee21297dd0a"
    ],
    "subject": "2a014e88ed7ab65cdfaa85daeab07eea6cba5e147f736edd8d02c2f9ddf0dec6",
    "index": 13
  },
  "containingBlock": {
    "height": 4976,
    "version": 2,
    "previousBlock": "449c60619294546ad825af03",
    "previousKeystone": "b0935637860679ddd5",
    "secondPreviousKeystone": "5ee4fd21082e18686e",
    "merkleRoot": "b53c1f4e259e6a0df23721a0b3b4b7ab",
    "timestamp": 1553699345,
    "difficulty": 117576138,
    "nonce": -266584319
  },
  "context": []
}

Package Sidebar

Install

npm i @veriblock/nodecore-parser

Weekly Downloads

4

Version

1.2.4

License

MIT

Unpacked Size

98.9 kB

Total Files

27

Last publish

Collaborators

  • warchant
  • delarq