lnwallet: add ListUnspentWitness to WalletController

This method has been added in order to allow lnd to collect eligible
unspent witness programs outputs from the wallet controller for use as
inputs to the funding transaction.

Additionally, the change address functions now also specify whether the
generated change address should be payable to a witness program or not.
This commit is contained in:
Olaoluwa Osuntokun 2016-04-12 21:36:41 -07:00
parent 5218dca5b6
commit f9a8dcbc9c
1 changed files with 13 additions and 6 deletions

View File

@ -26,7 +26,12 @@ type WalletController interface {
// NewAddress returns the next external address for the wallet. The
// type of address returned is dictated by the wallet's capabilities,
// and may be of type: p2sh, p2pkh, p2wkh, p2wsh, etc.
NewAddress() (btcutil.Address, error)
NewAddress(witness bool) (btcutil.Address, error)
// NewChangeAddress returns a new change address for the wallet. If the
// underlying wallet supports hd key chains, then this address should be
// dervied from an internal branch.
NewChangeAddress(witness bool) (btcutil.Address, error)
// GetPrivKey retrives the underlying private key associated with the
// passed address. If the wallet is unable to locate this private key
@ -34,11 +39,6 @@ type WalletController interface {
// error should be returned.
GetPrivKey(a *btcutil.Address) (*btcec.PrivateKey, error)
// NewChangeAddress returns a new change address for the wallet. If the
// underlying wallet supports hd key chains, then this address should be
// dervied from an internal branch.
NewChangeAddress() (btcutil.Address, error)
// NewRawKey returns a raw private key controlled by the wallet. These
// keys are used for the 2-of-2 multi-sig outputs for funding
// transactions, as well as the pub key used for commitment transactions.
@ -71,6 +71,13 @@ type WalletController interface {
// funds, or the outputs are non-standard, and error should be returned.
SendMany(outputs []*wire.TxOut) (*wire.ShaHash, error)
// ListUnspentWitness returns all unspent outputs which are version 0
// witness programs. The 'confirms' parameter indicates the minimum
// number of confirmations an output needs in order to be returned by
// this method. Passing -1 as 'confirms' indicates that even unconfirmed
// outputs should be returned.
ListUnspentWitness(confirms int32) ([]*wire.OutPoint, error)
// LockOutpoint marks an outpoint as locked meaning it will no longer
// be deemed as eligble for coin selection. Locking outputs are utilized
// in order to avoid race conditions when selecting inputs for usage when