{"id":25059654,"url":"https://github.com/0xb10c/rawtx","last_synced_at":"2025-04-14T13:57:10.366Z","repository":{"id":48925791,"uuid":"204545458","full_name":"0xB10C/rawtx","owner":"0xB10C","description":"A Golang module that helps you answer questions about raw Bitcoin transactions, their inputs, outputs and scripts.","archived":false,"fork":false,"pushed_at":"2024-10-10T16:46:26.000Z","size":188,"stargazers_count":17,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T03:03:52.467Z","etag":null,"topics":["bitcoin","golang","input","output","script","transaction","type"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/0xB10C/rawtx","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xB10C.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":"2019-08-26T19:21:15.000Z","updated_at":"2024-08-12T19:52:23.000Z","dependencies_parsed_at":"2024-06-19T16:23:43.890Z","dependency_job_id":"456c6ebc-ec52-4f2f-9f40-36cfdb4f7797","html_url":"https://github.com/0xB10C/rawtx","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xB10C%2Frawtx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xB10C%2Frawtx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xB10C%2Frawtx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xB10C%2Frawtx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xB10C","download_url":"https://codeload.github.com/0xB10C/rawtx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248893677,"owners_count":21179065,"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":["bitcoin","golang","input","output","script","transaction","type"],"created_at":"2025-02-06T15:35:54.686Z","updated_at":"2025-04-14T13:57:10.339Z","avatar_url":"https://github.com/0xB10C.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rawtx\n\n[![](https://godoc.org/github.com/0xB10C/rawtx?status.svg)](https://godoc.org/github.com/0xB10C/rawtx)\n[![](http://gocover.io/_badge/github.com/0xB10C/rawtx)](https://gocover.io/github.com/0xB10C/rawtx)\n[![](https://goreportcard.com/badge/github.com/0xb10c/rawtx)](https://goreportcard.com/report/github.com/0xb10c/rawtx)\n\nA Golang module that helps you answer questions about raw bitcoin transactions, their inputs, outputs and scripts.\n\n### Transactions\n\nTransactions can be deserialized [from a hex string][50] or [from][51] a [wire.MsgTx][52].\nBased on that following questions can be answered.\n\n- [x] [How many inputs?][60]\n- [x] [How many outputs?][61]\n- [x] [Whats the sum of all ouputs?][70]\n- [x] [Spends SegWit?][62]\n- [x] [Spends nested SegWit?][63]\n- [x] [Spends native SegWit?][64]\n- [x] [Spends multisig?][65]\n- [x] [What is the locktime?][66]\n- [x] [Is a coinbase transaction?][67]\n- [x] [Is BIP69 compliant?][68] _Wait, what is [BIP-69](https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki)?_\n- [x] [Signals explicit RBF?][69]\n- [x] [Whats the size in bytes?][71]\n- [x] [Whats the vsize in vbytes?][72]\n- [x] [and more...][more]\n\n[50]: https://www.godoc.org/github.com/0xb10c/rawtx/#StringToTx\n[51]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.FromWireMsgTx\n[52]: https://godoc.org/github.com/btcsuite/btcd/wire#MsgTx\n\n[60]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.GetNumInputs\n[61]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.GetNumOutputs\n[62]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.IsSpendingSegWit\n[63]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.IsSpendingNestedSegWit\n[64]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.IsSpendingNativeSegWit\n[65]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.SpendsMultisig\n[66]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.GetLocktime\n[67]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.IsCoinbase\n[68]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.IsBIP69Compliant\n[69]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.IsExplicitlyRBFSignaling\n[70]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.GetOutputSum\n[71]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.GetSizeWithWitness\n[72]: https://www.godoc.org/github.com/0xb10c/rawtx/#Tx.GetSizeWithoutWitness\n\n### Input and Output type\n\n- [x] [What type has this input?][24]\n- [x] [What type has this output?][25]\n\nFollowing is answered:\n\n|             |  spends?  |  pays to? |\n|-------------|:-------:|:-------:|\n| P2PK        | [✓][01] | [✓][02] |\n| P2PKH       | [✓][03] | [✓][04] |\n| P2SH-P2WPKH | [✓][05] | can't tell \u003cbr\u003e from  the rawtx |\n| P2WPKH_V0   | [✓][07] | [✓][08] |\n| P2MS        | [✓][09] | [✓][10] |\n| P2SH        | [✓][11] | [✓][12] |\n| P2SH-P2WSH  | [✓][13] | can't tell \u003cbr\u003e from the rawtx |\n| P2WSH_V0    | [✓][15] | [✓][16] |\n| OP_RETURN   | can't spend an \u003cbr\u003e `OP_RETURN` output | [✓][18] |\n\nAdditionally you might ask:\n\n- What is the reedem script of this [P2SH][20], [P2SH-P2WSH][21] or [P2WSH_V0][22] input?\n- What is the [OP_RETURN data pushed][23] by this output?\n- and is this [input unilitteraly closing a lightning channel?][26]\n\n[01]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.SpendsP2PK\n[02]: https://www.godoc.org/github.com/0xb10c/rawtx/#Output.IsP2PKOutput\n[03]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.SpendsP2PKH\n[04]: https://www.godoc.org/github.com/0xb10c/rawtx/#Output.IsP2PKHOutput\n[05]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.SpendsNestedP2WPKH\n[07]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.SpendsP2PKH\n[08]: https://www.godoc.org/github.com/0xb10c/rawtx/#Output.IsP2WPKHV0Output\n[09]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.SpendsP2MS\n[10]: https://www.godoc.org/github.com/0xb10c/rawtx/#Output.IsP2MSOutput\n[11]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.SpendsP2SH\n[12]: https://www.godoc.org/github.com/0xb10c/rawtx/#Output.IsP2SHOutput\n[13]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.SpendsNestedP2WSH\n[15]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.SpendsP2WSH\n[16]: https://www.godoc.org/github.com/0xb10c/rawtx/#Output.IsP2WSHV0Output\n[18]: https://www.godoc.org/github.com/0xb10c/rawtx/#Output.IsOPReturnOutput\n\n[20]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.GetP2SHRedeemScript\n[21]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.GetNestedP2WSHRedeemScript\n[22]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.GetP2WSHRedeemScript\n[23]: https://www.godoc.org/github.com/0xb10c/rawtx/#Output.GetOPReturnData\n[24]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.GetType\n[25]: https://www.godoc.org/github.com/0xb10c/rawtx/#Output.GetType\n[26]: https://www.godoc.org/github.com/0xb10c/rawtx/#Input.IsLNUniliteralClosing\n\n## Bitcoin Script\n\nThere is a [BitcoinScript][30] parser for byte slices build in.\nA [ParsedBitcoinScript][31] is a slice of [ParsedOpCodes][32].\nIt has a `String()` method which displays the OP codes in a bitcoin developer readable format.\n\n```go away\nbs1 := BitcoinScript{0x6e, 0x87, 0x91, 0x69, 0xa7, 0x7c, 0xa7, 0x87}\npbs1 := bs1.Parse()\nfmt.Println(pbs1.String())\n// -\u003e OP_2DUP OP_EQUAL OP_NOT OP_VERIFY OP_SHA1 OP_SWAP OP_SHA1 OP_EQUAL\n```\n\n```go awayy\nbs2 = BitcoinScript{byte(OpRETURN), byte(OpDATA2), byte(OpCHECKLOCKTIMEVERIFY), byte(OpDATA12)}\npbs2 = bs2.Parse()\nfmt.Println(pbs2.String())\n// -\u003e OP_RETURN OP_DATA_2(b10c)\n```\n\nThe actual [OpCode][33] behind the ParsedOpCode can, but doesn't have to push data. You can check if a ParsedOpCode is\n- [x] a [signature?][34] (and [what's the SigHash?][37])\n- [x] a [compressed public key?][35]\n- [x] an [uncompressed public key?][36]\n- [x] or either a [compressed or uncompressed public key?][38]\n- [x] or compare it any other OpCode.\n\n[30]: https://www.godoc.org/github.com/0xb10c/rawtx/#BitcoinScript\n[31]: https://www.godoc.org/github.com/0xb10c/rawtx/#ParsedBitcoinScript\n[32]: https://www.godoc.org/github.com/0xb10c/rawtx/#ParsedOpCode\n[33]: https://www.godoc.org/github.com/0xb10c/rawtx/#OpCode\n[34]: https://www.godoc.org/github.com/0xb10c/rawtx/#ParsedOpCode.IsSignature\n[35]: https://www.godoc.org/github.com/0xb10c/rawtx/#ParsedOpCode.IsCompressedPubKey\n[36]: https://www.godoc.org/github.com/0xb10c/rawtx/#ParsedOpCode.IsUncompressedPubKey\n[37]: https://www.godoc.org/github.com/0xb10c/rawtx/#ParsedOpCode.GetSigHash\n[38]: https://www.godoc.org/github.com/0xb10c/rawtx/#ParsedOpCode.IsPubKey\n\n\n[more]: https://www.godoc.org/github.com/0xb10c/rawtx/#pkg-index\n\n## Running tests\n\nEither normal test suit with coverage report in percent.\n\n```bash\n$ make test\n...\nPASS\ncoverage: 100.0% of statements\nok      github.com/0xB10C/rawtx 0.028s\n```\n\nOr with detailed coverage HTML report opened in your browser.\n\n```bash\n$ make cover\n...\nPASS\ncoverage: 100.0% of statements\nok      github.com/0xB10C/rawtx 0.028s\ngo tool cover -html=count.out\n```\n\n## Discalimer\n\nDo not use in consensus related code!\n\n## License\n\nrawTx is licensed under a BSD 3-Clause License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xb10c%2Frawtx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xb10c%2Frawtx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xb10c%2Frawtx/lists"}