Version: v0.6.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2019 License: ISC, BSD-3-Clause Imports: 9 Imported by: 0



Cut down version of: github.com/bitgoin/tx See that repo for further info

This has the following changes

  • P2SH functions have been removed as they are not used by this program
  • P2PK now call a better base58decoder
    • the bigoin/address/DecodeAddress is broken and just drops the version byte
    • this call was replace by function correctly decodes Bitcoin/Litecoin address versions
    • now unsupported address will cause error rather than the original generation of nonredeemable TXO
  • P2PK will work with scriptPubKey.type of "scripthash" and "pubkeyhash"




View Source
const (

	//Unit is unit to convert BTC to satoshi
	Unit = 100000000


This section is empty.


func DefaultP2PKScript

func DefaultP2PKScript(btcadr string) ([]byte, error)

DefaultP2PKScript returns default p2pk script.

func FillP2PKsign

func FillP2PKsign(result *Tx, used []*UTXO) error

FillP2PKsign embeds sign script to result Tx.

func NewP2PKunsign

func NewP2PKunsign(fee uint64, coins UTXOs, locktime uint32, sends ...*Send) (*Tx, []*UTXO, error)

NewP2PKunsign creates msg.Tx from send infos without signing tx.. last index of sends must be refund address, and its amount must be 0..


type Send

type Send struct {
	Addr   string
	Amount uint64

Send is information about addrress and amount to send.

type Tx

type Tx struct {
	Version  uint32
	TxIn     []*TxIn  `len:"prefix"`
	TxOut    []*TxOut `len:"prefix"`
	Locktime uint32

Tx describes a bitcoin transaction,

func (*Tx) Pack

func (t *Tx) Pack() ([]byte, error)

Pack packs Tx struct to bin.

type TxIn

type TxIn struct {
	Hash   []byte `len:"32"`
	Index  uint32
	Script []byte `len:"prefix"`
	Seq    uint32

TxIn is the info of input transaction.

type TxOut

type TxOut struct {
	Value  uint64
	Script []byte `len:"prefix"`

TxOut is the info of output transaction.

func CustomTx

func CustomTx(data []byte) *TxOut

CustomTx returns OP_RETURN txout with the custome data.

type UTXO

type UTXO struct {
	Key     *bgaddress.PrivateKey
	TxHash  []byte
	Value   uint64
	Script  []byte
	TxIndex uint32

UTXO represents an available transaction.

type UTXOs

type UTXOs []*UTXO

UTXOs is array of coins.

func (UTXOs) Len

func (c UTXOs) Len() int

func (UTXOs) Less

func (c UTXOs) Less(i, j int) bool

func (UTXOs) Swap

func (c UTXOs) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL