From 87c8165f01e79db04be6045889661824789f9b2c Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 11 Jul 2019 13:14:37 +0200 Subject: [PATCH] mock: make it possible to set list of returned utxos --- mock.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mock.go b/mock.go index 657069f4..cb4892ed 100644 --- a/mock.go +++ b/mock.go @@ -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),