btc

package
v4.5.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SignTransaction

func SignTransaction(
	keystores *keystore.Keystores,
	txProposal *maketx.TxProposal,
	previousOutputs map[wire.OutPoint]*transactions.SpendableOutput,
	getAddress func(blockchain.ScriptHashHex) *addresses.AccountAddress,
	log *logrus.Entry,
) error

SignTransaction signs all inputs. It assumes all outputs spent belong to this wallet. previousOutputs must contain all outputs which are spent by the transaction.

func XPubVersionForScriptType

func XPubVersionForScriptType(coin *Coin, scriptType signing.ScriptType) [4]byte

XPubVersionForScriptType returns the xpub version bytes for the given coin and script type.

Types

type Account

type Account struct {
	locker.Locker
	// contains filtered or unexported fields
}

Account is a account whose addresses are derived from an xpub.

func NewAccount

func NewAccount(
	coin *Coin,
	dbFolder string,
	code string,
	name string,
	getSigningConfiguration func() (*signing.Configuration, error),
	keystores *keystore.Keystores,
	getNotifier func(*signing.Configuration) accounts.Notifier,
	onEvent func(accounts.Event),
	log *logrus.Entry,
) *Account

NewAccount creates a new account.

func (*Account) Balance

func (account *Account) Balance() *accounts.Balance

Balance implements the interface.

func (*Account) Close

func (account *Account) Close()

Close stops the account.

func (*Account) Code

func (account *Account) Code() string

Code returns the code of the account.

func (*Account) Coin

func (account *Account) Coin() coin.Coin

Coin returns the coin of the account.

func (*Account) ConvertToLegacyAddress

func (account *Account) ConvertToLegacyAddress(addressID string) (btcutil.Address, error)

ConvertToLegacyAddress converts a ltc p2sh address to the legacy format (starting with '3'). Returns an error for non litecoin p2sh accounts.

func (*Account) FeeTargets

func (account *Account) FeeTargets() ([]accounts.FeeTarget, accounts.FeeTargetCode)

FeeTargets returns the fee targets and the default fee target.

func (*Account) GetUnusedReceiveAddresses

func (account *Account) GetUnusedReceiveAddresses() []accounts.Address

GetUnusedReceiveAddresses returns a number of unused addresses.

func (*Account) Info

func (account *Account) Info() *accounts.Info

Info returns account info, such as the signing configuration (xpubs).

func (*Account) Initialize

func (account *Account) Initialize() error

Initialize initializes the account.

func (*Account) Initialized

func (account *Account) Initialized() bool

Initialized indicates whether the account has loaded and finished the initial sync of the addresses.

func (*Account) Keystores

func (account *Account) Keystores() *keystore.Keystores

Keystores returns the keystores of the account.

func (*Account) Name

func (account *Account) Name() string

Name returns the name of the account.

func (*Account) Notifier

func (account *Account) Notifier() accounts.Notifier

Notifier implements accounts.Interface.

func (*Account) Offline

func (account *Account) Offline() bool

Offline returns true if the account is disconnected from the blockchain.

func (*Account) SendTx

func (account *Account) SendTx(
	recipientAddress string,
	amount coin.SendAmount,
	feeTargetCode accounts.FeeTargetCode,
	selectedUTXOs map[wire.OutPoint]struct{},
	_ []byte,
) error

SendTx creates, signs and sends tx which sends `amount` to the recipient.

func (*Account) SpendableOutputs

func (account *Account) SpendableOutputs() []*SpendableOutput

SpendableOutputs returns the utxo set, sorted by the value descending.

func (*Account) String

func (account *Account) String() string

String returns a representation of the account for logging.

func (*Account) Transactions

func (account *Account) Transactions() []accounts.Transaction

Transactions wraps transaction.Transactions.Transactions()

func (*Account) TxProposal

func (account *Account) TxProposal(
	recipientAddress string,
	amount coin.SendAmount,
	feeTargetCode accounts.FeeTargetCode,
	selectedUTXOs map[wire.OutPoint]struct{},
	_ []byte,
) (
	coin.Amount, coin.Amount, coin.Amount, error)

TxProposal creates a tx from the relevant input and returns information about it for display in the UI (the output amount and the fee). At the same time, it validates the input.

func (*Account) VerifyAddress

func (account *Account) VerifyAddress(addressID string) (bool, error)

VerifyAddress verifies a receive address on a keystore. Returns false, nil if no secure output exists.

type Coin

type Coin struct {
	observable.Implementation
	// contains filtered or unexported fields
}

Coin models a Bitcoin-related coin.

func NewCoin

func NewCoin(
	code string,
	unit string,
	net *chaincfg.Params,
	dbFolder string,
	servers []*rpc.ServerInfo,
	blockExplorerTxPrefix string,
) *Coin

NewCoin creates a new coin with the given parameters.

func (*Coin) BlockExplorerTransactionURLPrefix

func (coin *Coin) BlockExplorerTransactionURLPrefix() string

BlockExplorerTransactionURLPrefix implements coin.Coin.

func (*Coin) Blockchain

func (coin *Coin) Blockchain() blockchain.Interface

Blockchain connects to a blockchain backend.

func (*Coin) Code

func (coin *Coin) Code() string

Code implements coin.Coin.

func (*Coin) FormatAmount

func (coin *Coin) FormatAmount(amount coin.Amount) string

FormatAmount implements coin.Coin.

func (*Coin) Headers

func (coin *Coin) Headers() *headers.Headers

Headers returns the coin headers.

func (*Coin) Initialize

func (coin *Coin) Initialize()

Initialize implements coin.Coin.

func (*Coin) Net

func (coin *Coin) Net() *chaincfg.Params

Net returns the coin's network params.

func (*Coin) String

func (coin *Coin) String() string

func (*Coin) ToUnit

func (coin *Coin) ToUnit(amount coin.Amount) float64

ToUnit implements coin.Coin.

func (*Coin) Unit

func (coin *Coin) Unit() string

Unit implements coin.Coin.

type FeeTarget

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

FeeTarget contains the fee rate for a specific fee target.

func (*FeeTarget) Code

func (feeTarget *FeeTarget) Code() accounts.FeeTargetCode

Code returns the btc fee target

type ProposedTransaction

type ProposedTransaction struct {
	TXProposal      *maketx.TxProposal
	PreviousOutputs map[wire.OutPoint]*transactions.SpendableOutput
	GetAddress      func(blockchain.ScriptHashHex) *addresses.AccountAddress
	// Signatures collects the signatures (signatures[transactionInput][cosignerIndex]).
	Signatures [][]*btcec.Signature
	SigHashes  *txscript.TxSigHashes
}

ProposedTransaction contains all the info needed to sign a btc transaction.

type SpendableOutput

type SpendableOutput struct {
	*transactions.SpendableOutput
	OutPoint wire.OutPoint
}

SpendableOutput is an unspent coin.

type Status

type Status string

Status indicates the connection and initialization status.

const (
	// AccountSynced indicates that the account is synced.
	AccountSynced Status = "accountSynced"

	// AccountNotSynced indicates that the account is initialized, but not yet fully synced.
	AccountNotSynced Status = "accountNotSynced"

	// AccountDisabled indicates that the account has not yet been initialized.
	AccountDisabled Status = "accountDisabled"

	// OfflineMode indicates that the connection to the blockchain network could not be established.
	OfflineMode Status = "offlineMode"
)

Directories

Path Synopsis
db
client
Package client implements an Electrum JSON RPC client.
Package client implements an Electrum JSON RPC client.
Package maketx provides transaction creation code for wallets.
Package maketx provides transaction creation code for wallets.

Jump to

Keyboard shortcuts

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