txcore

package module
v0.0.0-...-3fc0518 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 13 Imported by: 0

README


TXCore

TXCore

The missing lightweight Bitcoin TX builder written in Go


Usage

    tx := txcore.NewTX()

    tx.AddInput("TxId", "Base58Address", outputIndex, isCompressed)
    tx.AddInput("TxId2", "AnotherBase58Address", output2Index, isCompressed)
    ...

    tx.AddOutput("abc", 100_000_000) // send one bitcoin to abc
    tx.AddOutput("xyz", 300_000_000) // send three bitcoins to xyz
    ...

    // Build raw tx
    tx.Build()

    // Sign with the corresponding private keys
    tx.Sign([]string{"privateKey1", "privateKey2", ...})

    // Print signed tx
    fmt.Println(tx.SignedTXHex)

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TX

type TX struct {
	Outputs []output // Public key of the output
	Inputs  []utxo

	RawTX       []byte
	SignedTX    []byte
	SignedTXHex string
}

TX struct

func NewTX

func NewTX() TX

NewTX return basic tx

func (*TX) AddInput

func (tx *TX) AddInput(txHash string, publicKey string, utxoIndex int, compressed bool) error

AddInput to the tx

func (*TX) AddOutput

func (tx *TX) AddOutput(base58address string, amount int) error

AddOutput to the tx

func (*TX) Build

func (tx *TX) Build() []byte

Build tx

func (*TX) Sign

func (tx *TX) Sign(privateKeys []string) error

Sign tx

Directories

Path Synopsis
Package base58 implements a human-friendly base58 encoding.
Package base58 implements a human-friendly base58 encoding.

Jump to

Keyboard shortcuts

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