Giter Club home page Giter Club logo

rawtx's Introduction

rawtx

A Golang module that helps you answer questions about raw bitcoin transactions, their inputs, outputs and scripts.

Transactions

Transactions can be deserialized from a hex string or from a wire.MsgTx. Based on that following questions can be answered.

Input and Output type

Following is answered:

spends? pays to?
P2PK
P2PKH
P2SH-P2WPKH can't tell
from the rawtx
P2WPKH_V0
P2MS
P2SH
P2SH-P2WSH can't tell
from the rawtx
P2WSH_V0
OP_RETURN can't spend an
OP_RETURN output

Additionally you might ask:

Bitcoin Script

There is a BitcoinScript parser for byte slices build in. A ParsedBitcoinScript is a slice of ParsedOpCodes. It has a String() method which displays the OP codes in a bitcoin developer readable format.

bs1 := BitcoinScript{0x6e, 0x87, 0x91, 0x69, 0xa7, 0x7c, 0xa7, 0x87}
pbs1 := bs1.Parse()
fmt.Println(pbs1.String())
// -> OP_2DUP OP_EQUAL OP_NOT OP_VERIFY OP_SHA1 OP_SWAP OP_SHA1 OP_EQUAL
bs2 = BitcoinScript{byte(OpRETURN), byte(OpDATA2), byte(OpCHECKLOCKTIMEVERIFY), byte(OpDATA12)}
pbs2 = bs2.Parse()
fmt.Println(pbs2.String())
// -> OP_RETURN OP_DATA_2(b10c)

The actual OpCode behind the ParsedOpCode can, but doesn't have to push data. You can check if a ParsedOpCode is

Running tests

Either normal test suit with coverage report in percent.

$ make test
...
PASS
coverage: 100.0% of statements
ok      github.com/0xB10C/rawtx 0.028s

Or with detailed coverage HTML report opened in your browser.

$ make cover
...
PASS
coverage: 100.0% of statements
ok      github.com/0xB10C/rawtx 0.028s
go tool cover -html=count.out

Discalimer

Do not use in consensus related code!

License

rawTx is licensed under a BSD 3-Clause License.

rawtx's People

Contributors

0xb10c avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rawtx's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.