{"id":15789909,"url":"https://github.com/gettocat/bitpony","last_synced_at":"2025-07-14T11:06:48.520Z","repository":{"id":94927156,"uuid":"101399634","full_name":"gettocat/bitPony","owner":"gettocat","description":"nodejs module to parse and create data and net packages on bitcoin protocol and talk with nodes","archived":false,"fork":false,"pushed_at":"2022-09-03T21:35:19.000Z","size":94,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-07T01:07:19.669Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gettocat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-25T12:00:57.000Z","updated_at":"2022-09-03T21:35:24.000Z","dependencies_parsed_at":"2023-04-19T09:33:42.754Z","dependency_job_id":null,"html_url":"https://github.com/gettocat/bitPony","commit_stats":{"total_commits":11,"total_committers":4,"mean_commits":2.75,"dds":0.5454545454545454,"last_synced_commit":"0e6af04f2f4336c79e6e7b89dd4a815b00828c22"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gettocat/bitPony","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2FbitPony","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2FbitPony/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2FbitPony/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2FbitPony/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gettocat","download_url":"https://codeload.github.com/gettocat/bitPony/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2FbitPony/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265281176,"owners_count":23739868,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T22:04:09.559Z","updated_at":"2025-07-14T11:06:48.461Z","avatar_url":"https://github.com/gettocat.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bitPony\r\nnodejs module to parse and create data and net packages on bitcoin protocol and talk with nodes\r\n\r\n# Get started\r\n\r\n```javascript\r\nvar bitPony = require('bitpony');\r\n```\r\n\r\n# Types\r\n\r\n## Simple\r\n\r\n```javascript\r\n//little Endian format (reverse byte order)\r\nconsole.log(bitPony.uint8.read(\"0f\"));//15\r\nconsole.log(bitPony.uint8.write(128).toString('hex'));//80\r\n\r\nconsole.log(bitPony.uint16.read(\"0ff0\"));//61455\r\nconsole.log(bitPony.uint16.write(35001).toString('hex'));//b988\r\n\r\nconsole.log(bitPony.uint32.read(\"ffff1000\"));//1114111\r\nconsole.log(bitPony.uint32.write(28000).toString('hex'));//606d0000\r\n\r\nconsole.log(bitPony.uint64.read(\"0000ff0000000000\"));//16711680\r\nconsole.log(bitPony.uint64.write(Math.pow(2, 50)).toString('hex'));//2**50 - 0000000000000400\r\n\r\nconsole.log(bitPony.char.read(\"626974636f696e206973207265616c206d6f6e6579\").toString());//bitcoin is real money\r\nconsole.log(bitPony.char.write(\"bitcoin is real money\").toString('hex'));//626974636f696e206973207265616c206d6f6e6579\r\n```\r\n\r\n## Bitcoin\r\n\r\n```javascript\r\n//var int - special bitcoin type: https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer\r\n//fd - for uint16, fe - for uint32, ff 0 fir uint64, other - number. If first byte less than fd - its number uint8\r\nconsole.log(bitPony.var_int.read(\"10\"));//16\r\nconsole.log(bitPony.var_int.write(250).toString('hex'));//fa\r\n\r\nconsole.log(bitPony.var_int.read(\"fdfe\"));//254\r\nconsole.log(bitPony.var_int.write(32000).toString('hex'));//fd007d\r\n\r\nconsole.log(bitPony.var_int.read(\"fda861\"));//25000\r\nconsole.log(bitPony.var_int.write(25000).toString('hex'));//fda861\r\n\r\nconsole.log(bitPony.var_int.read(\"ff0000000000000400\"));//2^50 1125899906842624\r\nconsole.log(bitPony.var_int.write(Math.pow(2, 50)).toString('hex'));//ff0000000000000400\r\n\r\n//string - is var_str, special bitcoin type: https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_string\r\n//first byte - var_int length of string, next lenbytes - str\r\nconsole.log(bitPony.string.read(\"124d79206e616d65206973204e616e6f636174\").toString());//My name is Nanocat\r\nconsole.log(bitPony.string.write(\"My name is Nanocat\").toString('hex'));\r\n\r\n//hash - network byte order user. so, to make hash - need char32 with reversed bytes\r\nconsole.log(bitPony.hash.read(\"4860eb18bf1b1620e37e9490fc8a427514416fd75159ab86688e9a8300000000\"));//00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048\r\nconsole.log(bitPony.hash.write(\"00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048\").toString('hex'));//4860eb18bf1b1620e37e9490fc8a427514416fd75159ab86688e9a8300000000\r\n\r\n```\r\n\r\n## Complex types\r\n\r\n### tx input\r\n\r\n```\r\n//input from tx https://blockchain.info/ru/tx/70f4c44126d1924a28a2bcc297f9a79abfb85e688ecacb520468448312c89ef7?format=hex\r\n { \r\n    hash: '612c0f25cda5ca7bcf6a3cad1a0a4c9c807b25e046ef939968b1c9d744791408',\r\n    index: 1,\r\n    scriptSig: '48304502...84b582b3fec',\r\n    script_len: 107,\r\n    sequence: 4294967295 \r\n }\r\n ```\r\n \r\n ```javascript\r\nconsole.log(bitPony.tx_in.read(\"08147944d7c9b1689993ef46e0257b809c4c0a1aad3c6acf7bcaa5cd250f2c61010000006b483045022100e5dad2ab845fdabf02279fb424618547723790fd29937db738f11580facf8af20220763831cc67e7dad729bbf893da8f4ee2afbd81539314044e1b060ff664581de30121026aa1ae66d5a08776adafa2752b9d26c8b3202d261e9e83687c23b84b582b3fecffffffff\"));\r\n\r\n//08147944d7c9b1689993ef46e0257b809c4c0a1aad3c6acf7bcaa5cd250f2c61010000006b483045022100e5dad2ab845fdabf02279fb424618547723790fd29937db738f11580facf8af20220763831cc67e7dad729bbf893da8f4ee2afbd81539314044e1b060ff664581de30121026aa1ae66d5a08776adafa2752b9d26c8b3202d261e9e83687c23b84b582b3fecffffffff\r\n\r\nconsole.log(bitPony.tx_in.write(\r\n\"612c0f25cda5ca7bcf6a3cad1a0a4c9c807b25e046ef939968b1c9d744791408\", \r\n1, \"48304502...84b582b3fec\", \r\n0xffffffff).toString('hex'));//hash, index, scriptSig, sequence \r\n```\r\n\r\n### tx out\r\n\r\n```\r\n//out from tx https://blockchain.info/ru/tx/8d4f4eb888a3130e31d1ac68045173e7a6b94a142843cde3c2fe74b64f3dd9da?format=hex\r\n \r\n { \r\n    amount: 4046768,\r\n    scriptPubKey: 'a91481987422b78e406c48511c30b7962030e8b4e06f87',\r\n    script_len: 23 \r\n }\r\n```\r\n \r\n ```javascript\r\nconsole.log(bitPony.tx_out.read(\"b0bf3d000000000017a91481987422b78e406c48511c30b7962030e8b4e06f87\"));\r\n\r\n//b0bf3d000000000017a91481987422b78e406c48511c30b7962030e8b4e06f87\r\nconsole.log(bitPony.tx_out.write(4046768, \"a91481987422b78e406c48511c30b7962030e8b4e06f87\").toString('hex'));\r\n```\r\n\r\n### tx\r\n\r\n```\r\n { \r\n    version: 1,\r\n    in_count: 176,\r\n    in: [ \r\n          { \r\n            hash: 'f83d0c94c1939037ec43e7231ee58bcbb05fa1ea9ac2e838cb3f340b85c931eb',\r\n            index: 67,\r\n            scriptSig: '47304402207fc2d....ba',\r\n            script_len: 138,\r\n            sequence: 4294967295 \r\n          },\r\n          //....\r\n    ]\r\n    out_count: 74,\r\n    out: [ \r\n           { \r\n            amount: 237327,\r\n            scriptPubKey: 'a9148962c0b9c89965ef3056ecc38860222b7815a35787',\r\n            script_len: 23 \r\n           },\r\n           //....\r\n    ],\r\n    lock_time: 0,\r\n    hash: 'b0dfddb20b270e7a5355e1035124bae6d6667e11702f54fad56b164df98e16e0',\r\n    length: 28513 \r\n }\r\n ```\r\n \r\n ```javascript\r\n //https://blockchain.info/ru/tx/8d4f4eb888a3130e31d1ac68045173e7a6b94a142843cde3c2fe74b64f3dd9da?format=hex\r\nconsole.log(bitPony.tx.read(\"txhex\"))\r\n\r\n\r\n//0100000001eb31...3578700000000\r\nconsole.log(bitPony.tx.write(1, [{//not real tx, just for test\r\n        hash: 'f83d0c94c1939037ec43e7231ee58bcbb05fa1ea9ac2e838cb3f340b85c931eb',\r\n        index: 67,\r\n        scriptSig: '47304402207fc2d3ba1c9f8260e7f2cb2222476ca0afd9046522bd014aafe93bc89a2d8000022058cb1dea497175e7504c0317ab601acb4919c1bfceb8ac3b50917640afcb3d200141046a11580e919a254797f72a42c52777fef4f7a2e0dbee4eabbb5790c52427f0986cdfe390b11d12a79f072389d37fb753222b23c5ccda336995b22de7733b60ba',\r\n        sequence: 4294967295\r\n    }], [{\r\n        amount: 237327,\r\n        scriptPubKey: 'a9148962c0b9c89965ef3056ecc38860222b7815a35787',\r\n    }], 0).toString('hex'));\r\n```\r\n\r\n### block header\r\n\r\n```\r\n//read first 81 byte from block: https://blockchain.info/block/00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048?format=hex\r\n { \r\n    version: 1,\r\n    prev_block: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',\r\n    merkle_root: '0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098',\r\n    timestamp: 1231469665,\r\n    bits: 486604799,\r\n    nonce: 2573394689,\r\n    txn_count: 1,\r\n    hash: '00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048' \r\n }\r\n ```\r\n \r\n ```javascript\r\nconsole.log(bitPony.header.read(\"010000006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000982051fd1e4ba744bbbe680e1fee14677ba1a3c3540bf7b1cdb606e857233e0e61bc6649ffff001d01e362990101\"));\r\n\r\n//010000006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000982051fd1e4ba744bbbe680e1fee14677ba1a3c3540bf7b1cdb606e857233e0e61bc6649ffff001d01e3629900\r\n//80 bytes, without last var_int (tx count - 01) byte\r\nconsole.log(bitPony.header.write(1,\r\n        '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',\r\n        '0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098',\r\n        1231469665,\r\n        486604799,\r\n        2573394689).toString('hex'));\r\n```\r\n\r\n# block\r\n\r\n```\r\n//block parsing\r\n//return:\r\n/*\r\n { \r\n version: 536870914,\r\n prev_block: '00000000000000000007126942a3353613c0a1793ac8d81bde244340d750f5e2',\r\n merkle_root: 'a30181a9f15bef9c1c42635d853de139677ded5e3eb1af1c8f5ca8a857908157',\r\n timestamp: 1503564603,\r\n bits: 402734313,\r\n nonce: 1728324334,\r\n txn_count: 2614,\r\n hash: '0000000000000000002f8bd6a1552596d822284e8fd3efa3fec200d548089cce' \r\n } \r\n \r\n 2614\r\n```\r\n\r\n```javascript\r\nhttps.request({\r\n    host: 'blockchain.info',\r\n    path: '/ru/block/0000000000000000002f8bd6a1552596d822284e8fd3efa3fec200d548089cce?format=hex'\r\n}, function (resp) {\r\n    var orighex = \"\";\r\n    resp.on('data', function (chunk) {\r\n        orighex += chunk;\r\n    });\r\n\r\n    resp.on('end', function () {\r\n        var orig = new Buffer(orighex, 'hex');\r\n        var b = bitPony.block.read(orig);//parse this transaction\r\n        console.log(b.header, b.txns.length)\r\n    });\r\n\r\n}).end();\r\n```\r\n\r\n## User types\r\n\r\nUser can create own types on bitPony base, use function bitPony.extend.\r\n\r\nMore examples in [wiki doc page](https://github.com/gettocat/bitPony/wiki/0-Get-started)\r\n\r\n# Contacts\r\n\r\nYou can write message about this project at my email: alex@letris.ru\r\n\r\n# Other language implementations\r\nJava: https://github.com/alexshadie/bitpony-java\r\n\r\n# Donate\r\n\r\nIf my project help to you, you can donate me in bitcoin: 1KFhXAzjip6UCn8Lu8iuwvK4TkwLbmyN7e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgettocat%2Fbitpony","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgettocat%2Fbitpony","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgettocat%2Fbitpony/lists"}