mock: make it possible to set list of returned utxos

This commit is contained in:
Johan T. Halseth 2019-07-11 13:14:37 +02:00
parent 2cd7d5a2a4
commit 87c8165f01
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -231,6 +231,7 @@ type mockWalletController struct {
prevAddres btcutil.Address
publishedTransactions chan *wire.MsgTx
index uint32
utxos []*lnwallet.Utxo
}
// BackEnd returns "mock" to signify a mock wallet controller.
@ -284,6 +285,13 @@ func (*mockWalletController) CreateSimpleTx(outputs []*wire.TxOut,
// need one unspent for the funding transaction.
func (m *mockWalletController) ListUnspentWitness(minconfirms,
maxconfirms int32) ([]*lnwallet.Utxo, error) {
// If the mock already has a list of utxos, return it.
if m.utxos != nil {
return m.utxos, nil
}
// Otherwise create one to return.
utxo := &lnwallet.Utxo{
AddressType: lnwallet.WitnessPubKey,
Value: btcutil.Amount(10 * btcutil.SatoshiPerBitcoin),