addresses

package
v4.14.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SigScriptWitnessSize

func SigScriptWitnessSize(configuration *signing.Configuration) (int, bool)

SigScriptWitnessSize returns the maximum possible sigscript size for a given address type.

Types

type AccountAddress

type AccountAddress struct {
	btcutil.Address

	// AccountConfiguration contains the absolute keypath and xpubs of the
	// account. AccountConfiguration + RelativeKeypath = Configuration.
	AccountConfiguration *signing.Configuration
	RelativeKeypath      signing.RelativeKeypath
	// Configuration contains the absolute keypath and the extended public keys of the address.
	Configuration *signing.Configuration

	// HistoryStatus is used to determine if the address status changed, and to determine if the
	// address has been used before or not. The status corresponds to
	// https://github.com/kyuupichan/electrumx/blob/46f245891cb62845f9eec0f9549526a7e569eb03/docs/protocol-basics.rst#status.
	HistoryStatus string
	// contains filtered or unexported fields
}

AccountAddress models an address that belongs to an account of the user. It contains all the information needed to receive and spend funds.

func NewAccountAddress

func NewAccountAddress(
	accountConfiguration *signing.Configuration,
	keyPath signing.RelativeKeypath,
	net *chaincfg.Params,
	log *logrus.Entry,
) *AccountAddress

NewAccountAddress creates a new account address.

func (*AccountAddress) EncodeForHumans

func (address *AccountAddress) EncodeForHumans() string

EncodeForHumans implements coin.EncodeForHumans.

func (*AccountAddress) ID

func (address *AccountAddress) ID() string

ID implements coin.Address.

func (*AccountAddress) PubkeyScript

func (address *AccountAddress) PubkeyScript() []byte

PubkeyScript returns the pubkey script of this address. Use this in a tx output to receive funds.

func (*AccountAddress) PubkeyScriptHashHex

func (address *AccountAddress) PubkeyScriptHashHex() blockchain.ScriptHashHex

PubkeyScriptHashHex returns the hash of the pubkey script in hex format. It is used to subscribe to notifications at the ElectrumX server.

func (*AccountAddress) ScriptForHashToSign

func (address *AccountAddress) ScriptForHashToSign() (bool, []byte)

ScriptForHashToSign returns whether this address is a segwit output and the script used when calculating the hash to be signed in a transaction. This info is needed when trying to spend from this address.

func (*AccountAddress) SignatureScript

func (address *AccountAddress) SignatureScript(
	signatures []*btcec.Signature,
) ([]byte, wire.TxWitness)

SignatureScript returns the signature script (and witness) needed to spend from this address. The signatures have to be provided in the order of the configuration (and some can be nil).

type AddressChain

type AddressChain struct {
	// contains filtered or unexported fields
}

AddressChain manages a chain of addresses derived from a configuration.

func NewAddressChain

func NewAddressChain(
	accountConfiguration *signing.Configuration,
	net *chaincfg.Params,
	gapLimit int,
	chainIndex uint32,
	log *logrus.Entry,
) *AddressChain

NewAddressChain creates an address chain starting at m/<chainIndex> from the given configuration.

func (*AddressChain) EnsureAddresses

func (addresses *AddressChain) EnsureAddresses() []*AccountAddress

EnsureAddresses appends addresses to the address chain until there are `gapLimit` unused unused ones, and returns the new addresses.

func (*AddressChain) GetUnused

func (addresses *AddressChain) GetUnused() []*AccountAddress

GetUnused returns the last `gapLimit` unused addresses. EnsureAddresses() must be called beforehand.

func (*AddressChain) LookupByScriptHashHex

func (addresses *AddressChain) LookupByScriptHashHex(hashHex blockchain.ScriptHashHex) *AccountAddress

LookupByScriptHashHex returns the address which matches the provided scriptHashHex. Returns nil if not found.

type SingleAddress

type SingleAddress struct {
	// contains filtered or unexported fields
}

SingleAddress manages a chain of addresses derived from a configuration.

func NewSingleAddress

func NewSingleAddress(
	accountConfiguration *signing.Configuration,
	net *chaincfg.Params,
	log *logrus.Entry,
) *SingleAddress

NewSingleAddress creates as single address starting at m/<chainIndex> from the given configuration.

func (*SingleAddress) EnsureAddresses

func (addresses *SingleAddress) EnsureAddresses() []*AccountAddress

EnsureAddresses returns the address

func (*SingleAddress) GetUnused

func (addresses *SingleAddress) GetUnused() []*AccountAddress

GetUnused returns the address

func (*SingleAddress) LookupByScriptHashHex

func (addresses *SingleAddress) LookupByScriptHashHex(hashHex blockchain.ScriptHashHex) *AccountAddress

LookupByScriptHashHex returns the address which matches the provided scriptHashHex. Returns nil if not found.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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