mock: make ListUnspentWitness return new outpoints each call
This commit is contained in:
parent
5b77ebddb2
commit
3afa16b7a6
13
mock.go
13
mock.go
@ -4,16 +4,17 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
|
||||||
"github.com/btcsuite/btcd/btcec"
|
"github.com/btcsuite/btcd/btcec"
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/txscript"
|
"github.com/btcsuite/btcd/txscript"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The block height returned by the mock BlockChainIO's GetBestBlock.
|
// The block height returned by the mock BlockChainIO's GetBestBlock.
|
||||||
@ -191,6 +192,7 @@ type mockWalletController struct {
|
|||||||
rootKey *btcec.PrivateKey
|
rootKey *btcec.PrivateKey
|
||||||
prevAddres btcutil.Address
|
prevAddres btcutil.Address
|
||||||
publishedTransactions chan *wire.MsgTx
|
publishedTransactions chan *wire.MsgTx
|
||||||
|
index uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// BackEnd returns "mock" to signify a mock wallet controller.
|
// BackEnd returns "mock" to signify a mock wallet controller.
|
||||||
@ -231,16 +233,17 @@ func (*mockWalletController) SendOutputs(outputs []*wire.TxOut,
|
|||||||
|
|
||||||
// ListUnspentWitness is called by the wallet when doing coin selection. We just
|
// ListUnspentWitness is called by the wallet when doing coin selection. We just
|
||||||
// need one unspent for the funding transaction.
|
// need one unspent for the funding transaction.
|
||||||
func (*mockWalletController) ListUnspentWitness(confirms int32) ([]*lnwallet.Utxo, error) {
|
func (m *mockWalletController) ListUnspentWitness(confirms int32) ([]*lnwallet.Utxo, error) {
|
||||||
utxo := &lnwallet.Utxo{
|
utxo := &lnwallet.Utxo{
|
||||||
AddressType: lnwallet.WitnessPubKey,
|
AddressType: lnwallet.WitnessPubKey,
|
||||||
Value: btcutil.Amount(10 * btcutil.SatoshiPerBitcoin),
|
Value: btcutil.Amount(10 * btcutil.SatoshiPerBitcoin),
|
||||||
PkScript: make([]byte, 22),
|
PkScript: make([]byte, 22),
|
||||||
OutPoint: wire.OutPoint{
|
OutPoint: wire.OutPoint{
|
||||||
Hash: chainhash.Hash{},
|
Hash: chainhash.Hash{},
|
||||||
Index: 0,
|
Index: m.index,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
atomic.AddUint32(&m.index, 1)
|
||||||
var ret []*lnwallet.Utxo
|
var ret []*lnwallet.Utxo
|
||||||
ret = append(ret, utxo)
|
ret = append(ret, utxo)
|
||||||
return ret, nil
|
return ret, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user