rawtx: github.com/0xB10C/rawtx Index | Files

package rawtx

import "github.com/0xB10C/rawtx"

Package rawtx helps you answer questions about raw bitcoin transactions, their inputs, outputs and scripts. More information https://github.com/0xB10C/rawtx

Index

Package Files

input.go opcodes.go output.go script.go testdata.go tx.go util.go

Variables

var OpCodeStringMap = map[OpCode]string{ /* 256 elements not displayed */

}

OpCodeStringMap maps op codes to their developer readable names

func HexDecodeRawTxString Uses

func HexDecodeRawTxString(rawTx string) (hexDecodedTx []byte, err error)

HexDecodeRawTxString hex decodes a rawTx string and returns it as byte slice.

type BitcoinScript Uses

type BitcoinScript []byte

BitcoinScript represents a bitcoin script as a byte slice A script can for example be the scriptPubKey or the scriptSig

func (BitcoinScript) IsMultisigScript Uses

func (s BitcoinScript) IsMultisigScript() (isMultisig bool, numRequiredSigs int, numPossiblePubKeys int)

IsMultisigScript checks if a passed BitcoinScript is multisig. Supported are P2SH, P2SH-P2WSH and P2WSH redeem scripts.

func (BitcoinScript) ParseWithPanic Uses

func (s BitcoinScript) ParseWithPanic() (parsed ParsedBitcoinScript)

ParseWithPanic parses a BitcoinScript and returns contained opcodes and data pushes separated as a ParsedBitcoinScript. Parse panics if a BitcoinScript can not be parsed!

func (BitcoinScript) PopFront Uses

func (s BitcoinScript) PopFront() (front ParsedOpCode, remainder BitcoinScript, err error)

PopFront returns the first OpCode and it's data push as a ParsedOpCode. Additionally the remaining BitcoinScript is returned.

type Input Uses

type Input struct {
    Outpoint  Outpoint
    ScriptSig BitcoinScript
    Sequence  uint32
    Witness   []BitcoinScript
    // contains filtered or unexported fields
}

Input represents a bitcoin transaction input as a struct.

func (*Input) FromWireTxIn Uses

func (in *Input) FromWireTxIn(txIn *wire.TxIn)

FromWireTxIn populates an Input struct with values from a wire.TxIn.

func (*Input) GetNestedP2WSHRedeemScript Uses

func (in *Input) GetNestedP2WSHRedeemScript() (redeemScript BitcoinScript)

GetNestedP2WSHRedeemScript checks if the input spend is a Nested-P2WSH input and then returns the redeemScript. The returned redeemScript is empty if the input does not spend a Nested-P2WSH input.

func (*Input) GetP2SHRedeemScript Uses

func (in *Input) GetP2SHRedeemScript() (redeemScript BitcoinScript)

GetP2SHRedeemScript checks if the input spend is a P2SH input and then returns the redeemScript. The returned redeemScript is empty if the input does not spend a P2SH input.

func (*Input) GetP2WSHRedeemScript Uses

func (in *Input) GetP2WSHRedeemScript() (redeemScript BitcoinScript)

GetP2WSHRedeemScript checks if the input spend is a P2WSH input and then returns the redeemScript. The returned redeemScript is empty if the input does not spend a P2WSH input.

func (*Input) GetType Uses

func (in *Input) GetType() InputType

GetType retruns the input type as a InputType

func (*Input) HasWitness Uses

func (in *Input) HasWitness() bool

HasWitness returns a boolean indicating if an input has a witness

func (*Input) IsLNUniliteralClosing Uses

func (in *Input) IsLNUniliteralClosing() bool

IsLNUniliteralClosing checks if the input spend is a lightning network unilateral close.

  OP_IF
	  pubKey
  OP_ELSE
	  OP_DATA_X (i.e. CSV time) OP_CHECKSEQUENCEVERIFY OP_DROP pubKey
  OP_ENDIF
  OP_CHECKSIG

func (*Input) SpendsMultisig Uses

func (in *Input) SpendsMultisig() bool

SpendsMultisig checks if the input spend is a multisig input. Checked are P2MS, P2SH, P2SH-P2WSH and P2WSH inputs.

func (*Input) SpendsNativeSegWit Uses

func (in *Input) SpendsNativeSegWit() bool

SpendsNativeSegWit checks if the input spend is a native SegWit input. A native SegWit input has a witness but an empty scriptSig.

func (*Input) SpendsNestedP2WPKH Uses

func (in *Input) SpendsNestedP2WPKH() bool

SpendsNestedP2WPKH checks if the input spend is a nested P2WPKH input. A nested P2WPKH input has a witness and the scriptSig looks like OP_DATA_22(OP_0 OP_DATA_20(20 byte hash))

func (*Input) SpendsNestedP2WSH Uses

func (in *Input) SpendsNestedP2WSH() bool

SpendsNestedP2WSH checks if the input spend is a nested P2WSH input. A nested P2WSH input has a witness and the scriptSig looks like OP_DATA_34(OP_0 OP_DATA_32(32 byte hash))

func (*Input) SpendsNestedSegWit Uses

func (in *Input) SpendsNestedSegWit() bool

SpendsNestedSegWit checks if the input spend is a nested SegWit input. A nested SegWit input has an **not** empty scriptSig and a witness.

func (*Input) SpendsP2MS Uses

func (in *Input) SpendsP2MS() bool

SpendsP2MS checks if an input spends a P2MS input. A P2MS has no witness items and a scriptSig as follows: OP_0 <signature> [<signature>] [<signature>] (where [] means optional)

func (*Input) SpendsP2PK Uses

func (in *Input) SpendsP2PK() bool

SpendsP2PK checks if the input spend is a P2PK input. A P2PK input only contains the signature in the scriptSig. <signature>

func (*Input) SpendsP2PKH Uses

func (in *Input) SpendsP2PKH() (spendsP2PKH bool)

SpendsP2PKH checks if the input spend is a P2PKH input. <signature> <pubkey>

func (*Input) SpendsP2PKHWithIsCompressed Uses

func (in *Input) SpendsP2PKHWithIsCompressed() (spendsP2PKH bool, isCompressedPubKey bool)

SpendsP2PKHWithIsCompressed checks if the input spend is a P2PKH input. Additionally it returns a boolean indicating if the revealed pubkey is compressed. <signature> <pubkey>

func (*Input) SpendsP2SH Uses

func (in *Input) SpendsP2SH() (spendsP2SH bool)

SpendsP2SH checks if the input spend is a P2SH input. A P2SH input has a redeemscript push at the end of the scriptSig, which is neither a signature or a pubkey.

func (*Input) SpendsP2WPKH Uses

func (in *Input) SpendsP2WPKH() bool

SpendsP2WPKH checks if an input spends a P2WPKH input. A P2WPKH input has a empty scriptSig, but contains exactly two items in the witness: [signature, pubkey]

func (*Input) SpendsP2WSH Uses

func (in *Input) SpendsP2WSH() bool

SpendsP2WSH checks if an input spends a P2WSH input. Since all native SegWit inputs that aren't P2WPKH are probably P2WSH this function just returns the complement for all native SegWit transactions.

type InputType Uses

type InputType int

InputType defines the input type

const (
    InP2PK InputType = iota + 1
    InP2PKH
    InP2SH_P2WPKH
    InP2WPKH
    InP2MS
    InP2SH
    InP2SH_P2WSH
    InP2WSH
    InCOINBASE
    InUNKNOWN
)

Possible types a input can be

func (InputType) String Uses

func (it InputType) String() string

type OpCode Uses

type OpCode byte

OpCode represents a bitcoin operation code

const (
    Op0                   OpCode = 0x00
    OpDATA1               OpCode = 0x01
    OpDATA2               OpCode = 0x02
    OpDATA3               OpCode = 0x03
    OpDATA4               OpCode = 0x04
    OpDATA5               OpCode = 0x05
    OpDATA6               OpCode = 0x06
    OpDATA7               OpCode = 0x07
    OpDATA8               OpCode = 0x08
    OpDATA9               OpCode = 0x09
    OpDATA10              OpCode = 0x0a
    OpDATA11              OpCode = 0x0b
    OpDATA12              OpCode = 0x0c
    OpDATA13              OpCode = 0x0d
    OpDATA14              OpCode = 0x0e
    OpDATA15              OpCode = 0x0f
    OpDATA16              OpCode = 0x10
    OpDATA17              OpCode = 0x11
    OpDATA18              OpCode = 0x12
    OpDATA19              OpCode = 0x13
    OpDATA20              OpCode = 0x14
    OpDATA21              OpCode = 0x15
    OpDATA22              OpCode = 0x16
    OpDATA23              OpCode = 0x17
    OpDATA24              OpCode = 0x18
    OpDATA25              OpCode = 0x19
    OpDATA26              OpCode = 0x1a
    OpDATA27              OpCode = 0x1b
    OpDATA28              OpCode = 0x1c
    OpDATA29              OpCode = 0x1d
    OpDATA30              OpCode = 0x1e
    OpDATA31              OpCode = 0x1f
    OpDATA32              OpCode = 0x20
    OpDATA33              OpCode = 0x21
    OpDATA34              OpCode = 0x22
    OpDATA35              OpCode = 0x23
    OpDATA36              OpCode = 0x24
    OpDATA37              OpCode = 0x25
    OpDATA38              OpCode = 0x26
    OpDATA39              OpCode = 0x27
    OpDATA40              OpCode = 0x28
    OpDATA41              OpCode = 0x29
    OpDATA42              OpCode = 0x2a
    OpDATA43              OpCode = 0x2b
    OpDATA44              OpCode = 0x2c
    OpDATA45              OpCode = 0x2d
    OpDATA46              OpCode = 0x2e
    OpDATA47              OpCode = 0x2f
    OpDATA48              OpCode = 0x30
    OpDATA49              OpCode = 0x31
    OpDATA50              OpCode = 0x32
    OpDATA51              OpCode = 0x33
    OpDATA52              OpCode = 0x34
    OpDATA53              OpCode = 0x35
    OpDATA54              OpCode = 0x36
    OpDATA55              OpCode = 0x37
    OpDATA56              OpCode = 0x38
    OpDATA57              OpCode = 0x39
    OpDATA58              OpCode = 0x3a
    OpDATA59              OpCode = 0x3b
    OpDATA60              OpCode = 0x3c
    OpDATA61              OpCode = 0x3d
    OpDATA62              OpCode = 0x3e
    OpDATA63              OpCode = 0x3f
    OpDATA64              OpCode = 0x40
    OpDATA65              OpCode = 0x41
    OpDATA66              OpCode = 0x42
    OpDATA67              OpCode = 0x43
    OpDATA68              OpCode = 0x44
    OpDATA69              OpCode = 0x45
    OpDATA70              OpCode = 0x46
    OpDATA71              OpCode = 0x47
    OpDATA72              OpCode = 0x48
    OpDATA73              OpCode = 0x49
    OpDATA74              OpCode = 0x4a
    OpDATA75              OpCode = 0x4b
    OpPUSHDATA1           OpCode = 0x4c
    OpPUSHDATA2           OpCode = 0x4d
    OpPUSHDATA4           OpCode = 0x4e
    Op1NEGATE             OpCode = 0x4f
    OpRESERVED            OpCode = 0x50
    Op1                   OpCode = 0x51
    OpTRUE                OpCode = 0x51
    Op2                   OpCode = 0x52
    Op3                   OpCode = 0x53
    Op4                   OpCode = 0x54
    Op5                   OpCode = 0x55
    Op6                   OpCode = 0x56
    Op7                   OpCode = 0x57
    Op8                   OpCode = 0x58
    Op9                   OpCode = 0x59
    Op10                  OpCode = 0x5a
    Op11                  OpCode = 0x5b
    Op12                  OpCode = 0x5c
    Op13                  OpCode = 0x5d
    Op14                  OpCode = 0x5e
    Op15                  OpCode = 0x5f
    Op16                  OpCode = 0x60
    OpNOP                 OpCode = 0x61
    OpVER                 OpCode = 0x62
    OpIF                  OpCode = 0x63
    OpNOTIF               OpCode = 0x64
    OpVERIF               OpCode = 0x65
    OpVERNOTIF            OpCode = 0x66
    OpELSE                OpCode = 0x67
    OpENDIF               OpCode = 0x68
    OpVERIFY              OpCode = 0x69
    OpRETURN              OpCode = 0x6a
    OpTOALTSTACK          OpCode = 0x6b
    OpFROMALTSTACK        OpCode = 0x6c
    Op2DROP               OpCode = 0x6d
    Op2DUP                OpCode = 0x6e
    Op3DUP                OpCode = 0x6f
    Op2OVER               OpCode = 0x70
    Op2ROT                OpCode = 0x71
    Op2SWAP               OpCode = 0x72
    OpIFDUP               OpCode = 0x73
    OpDEPTH               OpCode = 0x74
    OpDROP                OpCode = 0x75
    OpDUP                 OpCode = 0x76
    OpNIP                 OpCode = 0x77
    OpOVER                OpCode = 0x78
    OpPICK                OpCode = 0x79
    OpROLL                OpCode = 0x7a
    OpROT                 OpCode = 0x7b
    OpSWAP                OpCode = 0x7c
    OpTUCK                OpCode = 0x7d
    OpCAT                 OpCode = 0x7e
    OpSUBSTR              OpCode = 0x7f
    OpLEFT                OpCode = 0x80
    OpRIGHT               OpCode = 0x81
    OpSIZE                OpCode = 0x82
    OpINVERT              OpCode = 0x83
    OpAND                 OpCode = 0x84
    OpOR                  OpCode = 0x85
    OpXOR                 OpCode = 0x86
    OpEQUAL               OpCode = 0x87
    OpEQUALVERIFY         OpCode = 0x88
    OpRESERVED1           OpCode = 0x89
    OpRESERVED2           OpCode = 0x8a
    Op1ADD                OpCode = 0x8b
    Op1SUB                OpCode = 0x8c
    Op2MUL                OpCode = 0x8d
    Op2DIV                OpCode = 0x8e
    OpNEGATE              OpCode = 0x8f
    OpABS                 OpCode = 0x90
    OpNOT                 OpCode = 0x91
    Op0NOTEQUAL           OpCode = 0x92
    OpADD                 OpCode = 0x93
    OpSUB                 OpCode = 0x94
    OpMUL                 OpCode = 0x95
    OpDIV                 OpCode = 0x96
    OpMOD                 OpCode = 0x97
    OpLSHIFT              OpCode = 0x98
    OpRSHIFT              OpCode = 0x99
    OpBOOLAND             OpCode = 0x9a
    OpBOOLOR              OpCode = 0x9b
    OpNUMEQUAL            OpCode = 0x9c
    OpNUMEQUALVERIFY      OpCode = 0x9d
    OpNUMNOTEQUAL         OpCode = 0x9e
    OpLESSTHAN            OpCode = 0x9f
    OpGREATERTHAN         OpCode = 0xa0
    OpLESSTHANOREQUAL     OpCode = 0xa1
    OpGREATERTHANOREQUAL  OpCode = 0xa2
    OpMIN                 OpCode = 0xa3
    OpMAX                 OpCode = 0xa4
    OpWITHIN              OpCode = 0xa5
    OpRIPEMD160           OpCode = 0xa6
    OpSHA1                OpCode = 0xa7
    OpSHA256              OpCode = 0xa8
    OpHASH160             OpCode = 0xa9
    OpHASH256             OpCode = 0xaa
    OpCODESEPARATOR       OpCode = 0xab
    OpCHECKSIG            OpCode = 0xac
    OpCHECKSIGVERIFY      OpCode = 0xad
    OpCHECKMULTISIG       OpCode = 0xae
    OpCHECKMULTISIGVERIFY OpCode = 0xaf
    OpNOP1                OpCode = 0xb0
    OpCHECKLOCKTIMEVERIFY OpCode = 0xb1
    OpCHECKSEQUENCEVERIFY OpCode = 0xb2
    OpNOP4                OpCode = 0xb3
    OpNOP5                OpCode = 0xb4
    OpNOP6                OpCode = 0xb5
    OpNOP7                OpCode = 0xb6
    OpNOP8                OpCode = 0xb7
    OpNOP9                OpCode = 0xb8
    OpNOP10               OpCode = 0xb9
    OpUNKNOWN186          OpCode = 0xba
    OpUNKNOWN187          OpCode = 0xbb
    OpUNKNOWN188          OpCode = 0xbc
    OpUNKNOWN189          OpCode = 0xbd
    OpUNKNOWN190          OpCode = 0xbe
    OpUNKNOWN191          OpCode = 0xbf
    OpUNKNOWN192          OpCode = 0xc0
    OpUNKNOWN193          OpCode = 0xc1
    OpUNKNOWN194          OpCode = 0xc2
    OpUNKNOWN195          OpCode = 0xc3
    OpUNKNOWN196          OpCode = 0xc4
    OpUNKNOWN197          OpCode = 0xc5
    OpUNKNOWN198          OpCode = 0xc6
    OpUNKNOWN199          OpCode = 0xc7
    OpUNKNOWN200          OpCode = 0xc8
    OpUNKNOWN201          OpCode = 0xc9
    OpUNKNOWN202          OpCode = 0xca
    OpUNKNOWN203          OpCode = 0xcb
    OpUNKNOWN204          OpCode = 0xcc
    OpUNKNOWN205          OpCode = 0xcd
    OpUNKNOWN206          OpCode = 0xce
    OpUNKNOWN207          OpCode = 0xcf
    OpUNKNOWN208          OpCode = 0xd0
    OpUNKNOWN209          OpCode = 0xd1
    OpUNKNOWN210          OpCode = 0xd2
    OpUNKNOWN211          OpCode = 0xd3
    OpUNKNOWN212          OpCode = 0xd4
    OpUNKNOWN213          OpCode = 0xd5
    OpUNKNOWN214          OpCode = 0xd6
    OpUNKNOWN215          OpCode = 0xd7
    OpUNKNOWN216          OpCode = 0xd8
    OpUNKNOWN217          OpCode = 0xd9
    OpUNKNOWN218          OpCode = 0xda
    OpUNKNOWN219          OpCode = 0xdb
    OpUNKNOWN220          OpCode = 0xdc
    OpUNKNOWN221          OpCode = 0xdd
    OpUNKNOWN222          OpCode = 0xde
    OpUNKNOWN223          OpCode = 0xdf
    OpUNKNOWN224          OpCode = 0xe0
    OpUNKNOWN225          OpCode = 0xe1
    OpUNKNOWN226          OpCode = 0xe2
    OpUNKNOWN227          OpCode = 0xe3
    OpUNKNOWN228          OpCode = 0xe4
    OpUNKNOWN229          OpCode = 0xe5
    OpUNKNOWN230          OpCode = 0xe6
    OpUNKNOWN231          OpCode = 0xe7
    OpUNKNOWN232          OpCode = 0xe8
    OpUNKNOWN233          OpCode = 0xe9
    OpUNKNOWN234          OpCode = 0xea
    OpUNKNOWN235          OpCode = 0xeb
    OpUNKNOWN236          OpCode = 0xec
    OpUNKNOWN237          OpCode = 0xed
    OpUNKNOWN238          OpCode = 0xee
    OpUNKNOWN239          OpCode = 0xef
    OpUNKNOWN240          OpCode = 0xf0
    OpUNKNOWN241          OpCode = 0xf1
    OpUNKNOWN242          OpCode = 0xf2
    OpUNKNOWN243          OpCode = 0xf3
    OpUNKNOWN244          OpCode = 0xf4
    OpUNKNOWN245          OpCode = 0xf5
    OpUNKNOWN246          OpCode = 0xf6
    OpUNKNOWN247          OpCode = 0xf7
    OpUNKNOWN248          OpCode = 0xf8
    OpUNKNOWN249          OpCode = 0xf9
    OpSMALLINTEGER        OpCode = 0xfa
    OpPUBKEYS             OpCode = 0xfb
    OpUNKNOWN252          OpCode = 0xfc
    OpPUBKEYHASH          OpCode = 0xfd
    OpPUBKEY              OpCode = 0xfe
    OpINVALIDOPCODE       OpCode = 0xff
)

Bitcoin OP Codes. Mainly copied and adopted from https://github.com/btcsuite/btcd/blob/master/txscript/opcode.go

type Outpoint Uses

type Outpoint struct {
    PrevTxHash  [32]byte
    OutputIndex uint32
}

Outpoint represents a bitcoin transaction input's previous outpoint as a struct.

func (*Outpoint) FromWireOutpoint Uses

func (outpoint *Outpoint) FromWireOutpoint(wireOutpoint *wire.OutPoint)

FromWireOutpoint populates an Outpoint struct with values from a wire.OutPoint.

type Output Uses

type Output struct {
    Value        int64
    ScriptPubKey BitcoinScript
    // contains filtered or unexported fields
}

Output represents a bitcoin transaction output as a struct.

func (*Output) FromWireTxOut Uses

func (out *Output) FromWireTxOut(txOut *wire.TxOut)

FromWireTxOut populates an Output struct with values from a wire.TxOut.

func (*Output) GetOPReturnData Uses

func (out *Output) GetOPReturnData() (bool, ParsedOpCode)

GetOPReturnData returns a ParsedOpCode struct, which includes the Op Code and the data pushed by OP_RETURN. An OP_RETURN scriptPubKey looks like:

OP_RETURN <SomeDataPush> <OP_RETURN data>

func (*Output) GetType Uses

func (out *Output) GetType() OutputType

GetType retruns the output type as a OutputType

func (*Output) IsOPReturnOutput Uses

func (out *Output) IsOPReturnOutput() (is bool)

IsOPReturnOutput returns if an Output is an OP_RETURN output An OP_RETURN scriptPubKey looks like:

OP_RETURN <SomeDataPush> <OP_RETURN data>

func (*Output) IsP2MSOutput Uses

func (out *Output) IsP2MSOutput() (is bool, m int, n int)

IsP2MSOutput returns a boolean indicating if a output is a P2MS output A P2MS 1-of-2 scriptPubKey looks like:

OP_1 PubKey PubKey OP_2 OP_CHECKMULTISIG

func (*Output) IsP2PKHOutput Uses

func (out *Output) IsP2PKHOutput() bool

IsP2PKHOutput returns a boolean indicating if a output is a P2PKH output A P2PKH scriptPubKey looks like:

OP_DUP OP_HASH160 OP_DATA_20(20 byte pubKeyHash) OP_EQUALVERIFY OP_CHECKSIG
OP_DUP OP_HASH160 OP_DATA_20(                  ) OP_EQUALVERIFY OP_CHECKSIG

func (*Output) IsP2PKOutput Uses

func (out *Output) IsP2PKOutput() bool

IsP2PKOutput returns a boolean indicating if a output is a P2PK output A P2PK output looks like:

PubKey OP_CHECKSIG

func (*Output) IsP2SHOutput Uses

func (out *Output) IsP2SHOutput() bool

IsP2SHOutput returns a boolean indicating if a output is a P2SH output A P2SH scriptPubKey looks like:

OP_HASH160 OP_DATA_20(20 byte hash) OP_EQUAL

func (*Output) IsP2WPKHV0Output Uses

func (out *Output) IsP2WPKHV0Output() bool

IsP2WPKHV0Output returns a boolean indicating if a output is a P2WPKH output with witness program 0 A P2WPKH V0 output looks like:

OP_0 OP_DATA_20(20 byte hash) (where the leading OP_0 indicates witness program 0)

func (*Output) IsP2WSHV0Output Uses

func (out *Output) IsP2WSHV0Output() bool

IsP2WSHV0Output returns a boolean indicating if a output is a P2WSH output with witness program 0 A P2WSH V0 output looks like:

OP_0 (as witness program 0) OP_DATA_32(32 byte hash)

type OutputType Uses

type OutputType int

OutputType defines the input type

const (
    OutP2PK OutputType = iota + 1
    OutP2PKH
    OutP2WPKH
    OutP2MS
    OutP2SH
    OutP2WSH
    OutOPRETURN
    OutUNKNOWN
)

Possible types a output can be

func (OutputType) String Uses

func (ot OutputType) String() string

type ParsedBitcoinScript Uses

type ParsedBitcoinScript []ParsedOpCode

ParsedBitcoinScript is a parsed BitcoinScript

func (ParsedBitcoinScript) String Uses

func (pbs ParsedBitcoinScript) String() (s string)

type ParsedOpCode Uses

type ParsedOpCode struct {
    OpCode     OpCode
    PushedData []byte
}

ParsedOpCode respresents a OP Code as a part of a parsed BitcoinScript.

func (ParsedOpCode) GetSigHash Uses

func (poc ParsedOpCode) GetSigHash() (sighash byte)

GetSigHash returns the SIGHASH of a signature. If the passed ParsedOpCode does not push a Signature the returned SIGHASH is 0.

func (ParsedOpCode) IsCompressedPubKey Uses

func (poc ParsedOpCode) IsCompressedPubKey() bool

IsCompressedPubKey checks a two byte slices if they could represent a compressed public key. <pubkey length> <|pubkey|>

func (ParsedOpCode) IsPubKey Uses

func (poc ParsedOpCode) IsPubKey() bool

IsPubKey checks a two byte slices if they could represent a public key.

func (ParsedOpCode) IsPubKeyWithIsCompressed Uses

func (poc ParsedOpCode) IsPubKeyWithIsCompressed() (isPubKey bool, isCompressed bool)

IsPubKeyWithIsCompressed checks a two byte slices if they could represent a pubkey and if that pubkey is compressed.

func (ParsedOpCode) IsSignature Uses

func (poc ParsedOpCode) IsSignature() bool

IsSignature checks a two byte slices if they could represent a DER encoded signature. <sig length> <|signature|> <sig hash> While the signature looks like: <DER marker> <Sig length> <R marker> <R length> <|R value|> <S marker> <S length> <|S value|> <sig hash>

func (ParsedOpCode) IsUncompressedPubKey Uses

func (poc ParsedOpCode) IsUncompressedPubKey() bool

IsUncompressedPubKey checks a two byte slices if they could represent a uncompressed public key. <pubkey length> <|pubkey|>

func (*ParsedOpCode) String Uses

func (poc *ParsedOpCode) String() string

type Tx Uses

type Tx struct {
    Hash     string
    Version  int32
    Inputs   []Input
    Outputs  []Output
    Locktime uint32
    // contains filtered or unexported fields
}

Tx represents a bitcoin transaction as a struct.

func DeserializeRawTxBytes Uses

func DeserializeRawTxBytes(rawTx []byte) (tx Tx, err error)

DeserializeRawTxBytes returns a wire.MsgTx for a hex decoded rawTx as byte slice. If the rawTx is can't be deserialized an error is returned.

func StringToTx Uses

func StringToTx(rawTx string) (Tx, error)

StringToTx returns a wire.MsgTx for a raw transaction hex string

func (*Tx) FromWireMsgTx Uses

func (tx *Tx) FromWireMsgTx(wireTx *wire.MsgTx)

FromWireMsgTx populates a Tx struct with values from a wire.MsgTx.

func (*Tx) GetLocktime Uses

func (tx *Tx) GetLocktime() uint32

GetLocktime returns the locktime of the transaction

func (*Tx) GetNumInputs Uses

func (tx *Tx) GetNumInputs() int

GetNumInputs returns the number of inputs the transaction has

func (*Tx) GetNumOutputs Uses

func (tx *Tx) GetNumOutputs() int

GetNumOutputs returns the number of outputs the transaction has

func (*Tx) GetOutputSum Uses

func (tx *Tx) GetOutputSum() (sumOutputValues int64)

GetOutputSum returns the sum of all output values of the transaction in satoshi

func (*Tx) GetSizeWithWitness Uses

func (tx *Tx) GetSizeWithWitness() int

GetSizeWithWitness returns the transaction size **without** the witness stripped (size in bytes)

func (*Tx) GetSizeWithoutWitness Uses

func (tx *Tx) GetSizeWithoutWitness() int

GetSizeWithoutWitness returns the transaction size **with** the witness stripped (vsize in vbyte)

func (*Tx) HasOPReturnOutput Uses

func (tx *Tx) HasOPReturnOutput() bool

HasOPReturnOutput returns a boolean indicating if the transaction has a OP_RETURN output

func (*Tx) HasP2MSOutput Uses

func (tx *Tx) HasP2MSOutput() bool

HasP2MSOutput returns a boolean indicating if the transaction has a P2MS output

func (*Tx) HasP2PKHOutput Uses

func (tx *Tx) HasP2PKHOutput() bool

HasP2PKHOutput returns a boolean indicating if the transaction has a P2PKH output

func (*Tx) HasP2PKOutput Uses

func (tx *Tx) HasP2PKOutput() bool

HasP2PKOutput returns a boolean indicating if the transaction has a P2PK output

func (*Tx) HasP2SHOutput Uses

func (tx *Tx) HasP2SHOutput() bool

HasP2SHOutput returns a boolean indicating if the transaction has a P2SH output

func (*Tx) HasP2WPKHOutput Uses

func (tx *Tx) HasP2WPKHOutput() bool

HasP2WPKHOutput returns a boolean indicating if the transaction has a P2WPKH output

func (*Tx) HasP2WSHOutput Uses

func (tx *Tx) HasP2WSHOutput() bool

HasP2WSHOutput returns a boolean indicating if the transaction has a P2WSH output

func (*Tx) IsBIP69Compliant Uses

func (tx *Tx) IsBIP69Compliant() bool

IsBIP69Compliant returns a boolean indicating if the transaction is BIP 69 compliant

func (*Tx) IsCoinbase Uses

func (tx *Tx) IsCoinbase() bool

IsCoinbase returns a boolean indicating if a transaction is a coinbase transaction

func (*Tx) IsExplicitlyRBFSignaling Uses

func (tx *Tx) IsExplicitlyRBFSignaling() bool

IsExplicitlyRBFSignaling returns a boolean indicating if the transaction is explicitly signaling ReplaceByFee The transaction might still be implicitly able to be replaced by fee by e.g. a parent transaction signaling RBG

func (*Tx) IsSpendingMultisig Uses

func (tx *Tx) IsSpendingMultisig() bool

IsSpendingMultisig returns a boolean indicating if the transaction spends a multisig input

func (*Tx) IsSpendingNativeSegWit Uses

func (tx *Tx) IsSpendingNativeSegWit() bool

IsSpendingNativeSegWit returns a boolean indicating if the transaction spends native SegWit

func (*Tx) IsSpendingNestedSegWit Uses

func (tx *Tx) IsSpendingNestedSegWit() bool

IsSpendingNestedSegWit returns a boolean indicating if the transaction spends nested SegWit

func (*Tx) IsSpendingSegWit Uses

func (tx *Tx) IsSpendingSegWit() bool

IsSpendingSegWit returns a boolean indicating if a transaction spends SegWit inputs

Package rawtx imports 9 packages (graph). Updated 2019-09-28. Refresh now. Tools for package owners.