btc

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2019 License: Apache-2.0 Imports: 6 Imported by: 10

Documentation

Overview

Package btc defines primitives to work with Bitcoin.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownBitcoinNetwork is returned when the network ID associated to the WIF is unknown.
	ErrUnknownBitcoinNetwork = errors.New("WIF encoded private key uses unknown Bitcoin network")

	// ErrBadWIF is returned when the WIF encoded private key could not be decoded.
	ErrBadWIF = errors.New("Failed to decode WIF encoded private key")
)

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster interface {
	// Broadcast broadcasts a raw transaction.
	Broadcast(ctx context.Context, raw []byte) error
}

Broadcaster is able to broadcast raw Bitcoin transactions.

type Network

type Network string

Network represents a Bitcoin network.

const (
	// Component name for monitoring.
	Component = "btc"

	// NetworkTest3 is an identified for the test Bitcoin network.
	NetworkTest3 Network = "bitcoin:test3"

	// NetworkMain is an identified for the main Bitcoin network.
	NetworkMain Network = "bitcoin:main"
)

func GetNetworkFromWIF added in v0.3.1

func GetNetworkFromWIF(key string) (Network, error)

GetNetworkFromWIF returns the network ID associated to a bitcoin wallet.

func (Network) ID

func (n Network) ID() byte

ID returns the byte ID of the network.

func (Network) String

func (n Network) String() string

String implements fmt.Stringer.

type Output

type Output struct {
	TXHash   types.ReversedBytes32
	PKScript []byte
	Index    int
}

Output represents a transaction output.

type UnspentFinder

type UnspentFinder interface {
	// FindUnspent find unspent outputs for the given address and the
	// required amount.
	FindUnspent(ctx context.Context, address *types.ReversedBytes20, amount int64) (UnspentResult, error)
}

UnspentFinder is used to find unspent outputs.

type UnspentResult added in v0.3.1

type UnspentResult struct {
	// Outputs contains enough outputs to cover the requested amount.
	Outputs []Output

	// Sum is the sum of the balance of the returned outputs.
	Sum int64

	// Total is the sum all of the outputs including the returned outputs.
	Total int64
}

UnspentResult contains the result of a call to UnspentFinder.FindUnspent.

Directories

Path Synopsis
Package blockcypher defines primitives to work with the BlockCypher API.
Package blockcypher defines primitives to work with the BlockCypher API.
Package btctesting defines helpers to test Bitcoin.
Package btctesting defines helpers to test Bitcoin.
Package btctimestamper implements a fake Bitcoin timestamper which can be used for testing.
Package btctimestamper implements a fake Bitcoin timestamper which can be used for testing.

Jump to

Keyboard shortcuts

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