btcwallet

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2016 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BtcWallet

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

BtcWallet is an implementation of the lnwallet.WalletController interface backed by an active instance of btcwallet. At the time of the writing of this documentation, this implementation requires a full btcd node to operate.

func New

func New(cfg *Config) (*BtcWallet, error)

New returns a new fully initialized instance of BtcWallet given a valid confirguration struct.

func (*BtcWallet) ComputeInputScript

func (b *BtcWallet) ComputeInputScript(tx *wire.MsgTx,
	signDesc *lnwallet.SignDescriptor) (*lnwallet.InputScript, error)

ComputeInputScript generates a complete InputIndex for the passed transaction with the signature as defined within the passed SignDescriptor. This method is capable of generating the proper input script for both regular p2wkh output and p2wkh outputs nested within a regular p2sh output.

This is a part of the WalletController interface.

func (*BtcWallet) ConfirmedBalance

func (b *BtcWallet) ConfirmedBalance(confs int32, witness bool) (btcutil.Amount, error)

ConfirmedBalance returns the sum of all the wallet's unspent outputs that have at least confs confirmations. If confs is set to zero, then all unspent outputs, including those currently in the mempool will be included in the final sum.

This is a part of the WalletController interface.

func (*BtcWallet) FetchInputInfo

func (b *BtcWallet) FetchInputInfo(prevOut *wire.OutPoint) (*wire.TxOut, error)

FetchInputInfo queries for the WalletController's knowledge of the passed outpoint. If the base wallet determines this output is under its control, then the original txout should be returned. Otherwise, a non-nil error value of ErrNotMine should be returned instead.

This is a part of the WalletController interface.

func (*BtcWallet) FetchRootKey

func (b *BtcWallet) FetchRootKey() (*btcec.PrivateKey, error)

FetchRootKey returns a root key which is meanted to be used as an initial seed/salt to generate any Lightning specific secrets.

This is a part of the WalletController interface.

func (*BtcWallet) GetCurrentHeight

func (b *BtcWallet) GetCurrentHeight() (int32, error)

GetCurrentHeight returns the current height of the known block within the main chain.

This method is a part of the lnwallet.BlockChainIO interface.

func (*BtcWallet) GetPrivKey

func (b *BtcWallet) GetPrivKey(a btcutil.Address) (*btcec.PrivateKey, error)

GetPrivKey retrives the underlying private key associated with the passed address. If the we're unable to locate the proper private key, then a non-nil error will be returned.

This is a part of the WalletController interface.

func (*BtcWallet) GetTransaction

func (b *BtcWallet) GetTransaction(txid *wire.ShaHash) (*wire.MsgTx, error)

GetTransaction returns the full transaction identified by the passed transaction ID.

This method is a part of the lnwallet.BlockChainIO interface.

func (*BtcWallet) GetUtxo

func (b *BtcWallet) GetUtxo(txid *wire.ShaHash, index uint32) (*wire.TxOut, error)

GetTxOut returns the original output referenced by the passed outpoint.

This method is a part of the lnwallet.BlockChainIO interface.

func (*BtcWallet) ListUnspentWitness

func (b *BtcWallet) ListUnspentWitness(minConfs int32) ([]*lnwallet.Utxo, error)

ListUnspentWitness returns a slice of all the unspent outputs the wallet controls which pay to witness programs either directly or indirectly.

This is a part of the WalletController interface.

func (*BtcWallet) LockOutpoint

func (b *BtcWallet) LockOutpoint(o wire.OutPoint)

LockOutpoint marks an outpoint as locked meaning it will no longer be deemed as eligible for coin selection. Locking outputs are utilized in order to avoid race conditions when selecting inputs for usage when funding a channel.

This is a part of the WalletController interface.

func (*BtcWallet) NewAddress

func (b *BtcWallet) NewAddress(t lnwallet.AddressType, change bool) (btcutil.Address, error)

NewAddress returns the next external or internal address for the wallet dicatated by the value of the `change` paramter. If change is true, then an internal address will be returned, otherwise an external address should be returned.

This is a part of the WalletController interface.

func (*BtcWallet) NewRawKey

func (b *BtcWallet) NewRawKey() (*btcec.PublicKey, error)

NewRawKey retrieves the next key within our HD key-chain for use within as a multi-sig key within the funding transaction, or within the commitment transaction's outputs.

This is a part of the WalletController interface.

func (*BtcWallet) PublishTransaction

func (b *BtcWallet) PublishTransaction(tx *wire.MsgTx) error

PublishTransaction performs cursory validation (dust checks, etc), then finally broadcasts the passed transaction to the Bitcoin network.

func (*BtcWallet) SendOutputs

func (b *BtcWallet) SendOutputs(outputs []*wire.TxOut) (*wire.ShaHash, error)

SendOutputs funds, signs, and broadcasts a Bitcoin transaction paying out to the specified outputs. In the case the wallet has insufficient funds, or the outputs are non-standard, a non-nil error will be be returned.

This is a part of the WalletController interface.

func (*BtcWallet) SignOutputRaw

func (b *BtcWallet) SignOutputRaw(tx *wire.MsgTx, signDesc *lnwallet.SignDescriptor) ([]byte, error)

SignOutputRaw generates a signature for the passed transaction according to the data within the passed SignDescriptor.

This is a part of the WalletController interface.

func (*BtcWallet) Start

func (b *BtcWallet) Start() error

Start initializes the underlying rpc connection, the wallet itself, and begins syncing to the current available blockchain state.

This is a part of the WalletController interface.

func (*BtcWallet) Stop

func (b *BtcWallet) Stop() error

Stop signals the wallet for shutdown. Shutdown may entail closing any active sockets, database handles, stopping goroutines, etc.

This is a part of the WalletController interface.

func (*BtcWallet) UnlockOutpoint

func (b *BtcWallet) UnlockOutpoint(o wire.OutPoint)

UnlockOutpoint unlocks an previously locked output, marking it eligible for coin seleciton.

This is a part of the WalletController interface.

type Config

type Config struct {
	// DataDir is the name of the directory where the wallet's persistent
	// state should be sotred.
	DataDir string

	// LogDir is the name of the directory which should be used to store
	// generated log files.
	LogDir string

	// DebugLevel is a string representing the level of verbosity the
	// logger should use.
	DebugLevel string

	// RpcHost is the host and port to use to reach the rpc sever.
	RpcHost string // localhost:18334

	// RpcUser is the username which should be used to authentiate with the
	// rpc server.
	RpcUser string

	// RpcPass is the password which should be used to authenticate the
	// connection with the RPC server.
	RpcPass string

	// RpcNoTLS denotes if a TLS connection should be attempted when
	// connecting to the RPC server.
	RpcNoTLS bool

	// RPCCert directory where the TLS certificate of the RPC sever is
	// stored. If the RpcNoTLS is false, then this value will be unused.
	RPCCert string
	RPCKey  string

	// CACert is the raw RPC cert for btcd.
	CACert []byte

	PrivatePass []byte
	PublicPass  []byte
	HdSeed      []byte

	NetParams *chaincfg.Params
}

Config is a struct which houses configuration paramters which modify the instance of BtcWallet generated by the New() function.

Jump to

Keyboard shortcuts

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