mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
Merge pull request #3486 from joostjager/remove-unused
multi: remove dead code
This commit is contained in:
commit
2dd23819bb
@ -1,6 +1,15 @@
|
||||
run:
|
||||
# timeout for analysis
|
||||
deadline: 4m
|
||||
build-tags:
|
||||
- autopilotrpc
|
||||
- chainrpc
|
||||
- invoicesrpc
|
||||
- routerrpc
|
||||
- signrpc
|
||||
- walletrpc
|
||||
- watchtowerrpc
|
||||
- wtclientrpc
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
@ -16,3 +25,4 @@ linters:
|
||||
- gofmt
|
||||
- golint
|
||||
- govet
|
||||
- unused
|
||||
|
@ -102,10 +102,6 @@ const (
|
||||
// checkSumSize is the index within an enciphered cipher seed that
|
||||
// marks the start of the checksum.
|
||||
checkSumOffset = EncipheredCipherSeedSize - checkSumSize
|
||||
|
||||
// encipheredSeedSize is the size of the cipherseed before applying the
|
||||
// external version, salt, and checksum for the final encoding.
|
||||
encipheredSeedSize = DecipheredCipherSeedSize + CipherTextExpansion
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -8,13 +8,6 @@ import (
|
||||
"testing/quick"
|
||||
)
|
||||
|
||||
var (
|
||||
nID1 = NodeID([33]byte{1})
|
||||
nID2 = NodeID([33]byte{2})
|
||||
nID3 = NodeID([33]byte{3})
|
||||
nID4 = NodeID([33]byte{4})
|
||||
)
|
||||
|
||||
// TestWeightedChoiceEmptyMap tests that passing in an empty slice of weights
|
||||
// returns an error.
|
||||
func TestWeightedChoiceEmptyMap(t *testing.T) {
|
||||
@ -95,7 +88,6 @@ type nonNegative []float64
|
||||
// Generate generates a value of type nonNegative to be used during
|
||||
// QuickTests.
|
||||
func (nonNegative) Generate(rand *rand.Rand, size int) reflect.Value {
|
||||
const precision = 100
|
||||
w := make([]float64, size)
|
||||
|
||||
for i := range w {
|
||||
|
@ -74,10 +74,6 @@ var chanGraphs = []struct {
|
||||
// TestPrefAttachmentSelectEmptyGraph ensures that when passed an
|
||||
// empty graph, the NodeSores function always returns a score of 0.
|
||||
func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
|
||||
const (
|
||||
maxChanSize = btcutil.Amount(btcutil.SatoshiPerBitcoin)
|
||||
)
|
||||
|
||||
prefAttach := NewPrefAttachment()
|
||||
|
||||
// Create a random public key, which we will query to get a score for.
|
||||
@ -123,47 +119,6 @@ func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// completeGraph is a helper method that adds numNodes fully connected nodes to
|
||||
// the graph.
|
||||
func completeGraph(t *testing.T, g testGraph, numNodes int) {
|
||||
const chanCapacity = btcutil.SatoshiPerBitcoin
|
||||
nodes := make(map[int]*btcec.PublicKey)
|
||||
for i := 0; i < numNodes; i++ {
|
||||
for j := i + 1; j < numNodes; j++ {
|
||||
|
||||
node1 := nodes[i]
|
||||
node2 := nodes[j]
|
||||
edge1, edge2, err := g.addRandChannel(
|
||||
node1, node2, chanCapacity)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate channel: %v", err)
|
||||
}
|
||||
|
||||
if node1 == nil {
|
||||
pubKeyBytes := edge1.Peer.PubKey()
|
||||
nodes[i], err = btcec.ParsePubKey(
|
||||
pubKeyBytes[:], btcec.S256(),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to parse pubkey: %v",
|
||||
err)
|
||||
}
|
||||
}
|
||||
|
||||
if node2 == nil {
|
||||
pubKeyBytes := edge2.Peer.PubKey()
|
||||
nodes[j], err = btcec.ParsePubKey(
|
||||
pubKeyBytes[:], btcec.S256(),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to parse pubkey: %v",
|
||||
err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestPrefAttachmentSelectTwoVertexes ensures that when passed a
|
||||
// graph with only two eligible vertexes, then both are given the same score,
|
||||
// and the funds are appropriately allocated across each peer.
|
||||
|
@ -1982,19 +1982,3 @@ func forceStateTransition(chanA, chanB *lnwallet.LightningChannel) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// calcStaticFee calculates appropriate fees for commitment transactions. This
|
||||
// function provides a simple way to allow test balance assertions to take fee
|
||||
// calculations into account.
|
||||
//
|
||||
// TODO(bvu): Refactor when dynamic fee estimation is added.
|
||||
// TODO(conner) remove code duplication
|
||||
func calcStaticFee(numHTLCs int) btcutil.Amount {
|
||||
const (
|
||||
commitWeight = btcutil.Amount(724)
|
||||
htlcWeight = 172
|
||||
feePerKw = btcutil.Amount(24/4) * 1000
|
||||
)
|
||||
return feePerKw * (commitWeight +
|
||||
btcutil.Amount(htlcWeight*numHTLCs)) / 1000
|
||||
}
|
||||
|
@ -23,14 +23,6 @@ const (
|
||||
notifierType = "bitcoind"
|
||||
)
|
||||
|
||||
// chainUpdate encapsulates an update to the current main chain. This struct is
|
||||
// used as an element within an unbounded queue in order to avoid blocking the
|
||||
// main rpc dispatch rule.
|
||||
type chainUpdate struct {
|
||||
blockHash *chainhash.Hash
|
||||
blockHeight int32
|
||||
}
|
||||
|
||||
// TODO(roasbeef): generalize struct below:
|
||||
// * move chans to config
|
||||
// * extract common code
|
||||
@ -166,13 +158,6 @@ func (b *BitcoindNotifier) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// blockNtfn packages a notification of a connected/disconnected block along
|
||||
// with its height at the time.
|
||||
type blockNtfn struct {
|
||||
sha *chainhash.Hash
|
||||
height int32
|
||||
}
|
||||
|
||||
// notificationDispatcher is the primary goroutine which handles client
|
||||
// notification registrations, as well as notification dispatches.
|
||||
func (b *BitcoindNotifier) notificationDispatcher() {
|
||||
|
@ -8,15 +8,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
)
|
||||
|
||||
const (
|
||||
// dbName is the default name of the database storing the height hints.
|
||||
dbName = "heighthint.db"
|
||||
|
||||
// dbFilePermission is the default permission of the database file
|
||||
// storing the height hints.
|
||||
dbFilePermission = 0600
|
||||
)
|
||||
|
||||
var (
|
||||
// spendHintBucket is the name of the bucket which houses the height
|
||||
// hint for outpoints. Each height hint represents the earliest height
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
@ -33,7 +32,6 @@ var (
|
||||
0x86, 0xf4, 0xcb, 0xf9, 0x8e, 0xae, 0xd2, 0x21,
|
||||
0xb3, 0x0b, 0xd9, 0xa0, 0xb9, 0x28,
|
||||
}
|
||||
testScript, _ = txscript.ParsePkScript(testRawScript)
|
||||
)
|
||||
|
||||
type mockHintCache struct {
|
||||
|
@ -2298,23 +2298,6 @@ func serializeChannelCloseSummary(w io.Writer, cs *ChannelCloseSummary) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func fetchChannelCloseSummary(tx *bbolt.Tx,
|
||||
chanID []byte) (*ChannelCloseSummary, error) {
|
||||
|
||||
closedChanBucket, err := tx.CreateBucketIfNotExists(closedChannelBucket)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
summaryBytes := closedChanBucket.Get(chanID)
|
||||
if summaryBytes == nil {
|
||||
return nil, fmt.Errorf("closed channel summary not found")
|
||||
}
|
||||
|
||||
summaryReader := bytes.NewReader(summaryBytes)
|
||||
return deserializeCloseChannelSummary(summaryReader)
|
||||
}
|
||||
|
||||
func deserializeCloseChannelSummary(r io.Reader) (*ChannelCloseSummary, error) {
|
||||
c := &ChannelCloseSummary{}
|
||||
|
||||
@ -2679,13 +2662,6 @@ func makeLogKey(updateNum uint64) [8]byte {
|
||||
return key
|
||||
}
|
||||
|
||||
// readLogKey parse the first 8- bytes of a byte slice into a uint64.
|
||||
//
|
||||
// NOTE: The slice must be at least 8 bytes long.
|
||||
func readLogKey(b []byte) uint64 {
|
||||
return byteOrder.Uint64(b)
|
||||
}
|
||||
|
||||
func appendChannelLogEntry(log *bbolt.Bucket,
|
||||
commit *ChannelCommitment) error {
|
||||
|
||||
|
@ -11,7 +11,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
@ -23,23 +22,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
netParams = &chaincfg.TestNet3Params
|
||||
|
||||
key = [chainhash.HashSize]byte{
|
||||
0x81, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
|
||||
0x68, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
|
||||
0xd, 0xe7, 0x93, 0xe4, 0xb7, 0x25, 0xb8, 0x4d,
|
||||
0x1e, 0xb, 0x4c, 0xf9, 0x9e, 0xc5, 0x8c, 0xe9,
|
||||
}
|
||||
id = &wire.OutPoint{
|
||||
Hash: [chainhash.HashSize]byte{
|
||||
0x51, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
|
||||
0x48, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
|
||||
0x2d, 0xe7, 0x93, 0xe4, 0xb7, 0x25, 0xb8, 0x4d,
|
||||
0x1f, 0xb, 0x4c, 0xf9, 0x9e, 0xc5, 0x8c, 0xe9,
|
||||
},
|
||||
Index: 9,
|
||||
}
|
||||
rev = [chainhash.HashSize]byte{
|
||||
0x51, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
|
||||
0x48, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
|
||||
@ -77,10 +65,6 @@ var (
|
||||
},
|
||||
LockTime: 5,
|
||||
}
|
||||
testOutpoint = &wire.OutPoint{
|
||||
Hash: key,
|
||||
Index: 0,
|
||||
}
|
||||
privKey, pubKey = btcec.PrivKeyFromBytes(btcec.S256(), key[:])
|
||||
|
||||
wireSig, _ = lnwire.NewSigFromSignature(testSig)
|
||||
|
@ -15,9 +15,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/shachain"
|
||||
)
|
||||
|
||||
// outPointSize is the size of a serialized outpoint on disk.
|
||||
const outPointSize = 36
|
||||
|
||||
// writeOutpoint writes an outpoint to the passed writer using the minimal
|
||||
// amount of bytes possible.
|
||||
func writeOutpoint(w io.Writer, o *wire.OutPoint) error {
|
||||
|
@ -919,11 +919,6 @@ func uint16Key(i uint16) []byte {
|
||||
return key
|
||||
}
|
||||
|
||||
// uint16FromKey reconstructs a 16-bit unsigned integer from a 2-byte slice.
|
||||
func uint16FromKey(key []byte) uint16 {
|
||||
return byteOrder.Uint16(key)
|
||||
}
|
||||
|
||||
// Compile-time constraint to ensure that ChannelPackager implements the public
|
||||
// FwdPackager interface.
|
||||
var _ FwdPackager = (*ChannelPackager)(nil)
|
||||
|
@ -29,9 +29,7 @@ var (
|
||||
"[2001:db8:85a3:0:0:8a2e:370:7334]:80")
|
||||
testAddrs = []net.Addr{testAddr, anotherAddr}
|
||||
|
||||
randSource = prand.NewSource(time.Now().Unix())
|
||||
randInts = prand.New(randSource)
|
||||
testSig = &btcec.Signature{
|
||||
testSig = &btcec.Signature{
|
||||
R: new(big.Int),
|
||||
S: new(big.Int),
|
||||
}
|
||||
|
@ -101,14 +101,6 @@ func makeFakeInfo() (*PaymentCreationInfo, *PaymentAttemptInfo) {
|
||||
return c, a
|
||||
}
|
||||
|
||||
func makeFakePaymentHash() [32]byte {
|
||||
var paymentHash [32]byte
|
||||
rBytes, _ := randomBytes(0, 32)
|
||||
copy(paymentHash[:], rBytes)
|
||||
|
||||
return paymentHash
|
||||
}
|
||||
|
||||
// randomBytes creates random []byte with length in range [minLen, maxLen)
|
||||
func randomBytes(minLen, maxLen int) ([]byte, error) {
|
||||
randBuf := make([]byte, minLen+rand.Intn(maxLen-minLen))
|
||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -40,6 +40,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
@ -2818,37 +2818,6 @@ func describeGraph(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// normalizeFunc is a factory function which returns a function that normalizes
|
||||
// the capacity of edges within the graph. The value of the returned
|
||||
// function can be used to either plot the capacities, or to use a weight in a
|
||||
// rendering of the graph.
|
||||
func normalizeFunc(edges []*lnrpc.ChannelEdge, scaleFactor float64) func(int64) float64 {
|
||||
var (
|
||||
min float64 = math.MaxInt64
|
||||
max float64
|
||||
)
|
||||
|
||||
for _, edge := range edges {
|
||||
// In order to obtain saner values, we reduce the capacity of a
|
||||
// channel to its base 2 logarithm.
|
||||
z := math.Log2(float64(edge.Capacity))
|
||||
|
||||
if z < min {
|
||||
min = z
|
||||
}
|
||||
if z > max {
|
||||
max = z
|
||||
}
|
||||
}
|
||||
|
||||
return func(x int64) float64 {
|
||||
y := math.Log2(float64(x))
|
||||
|
||||
// TODO(roasbeef): results in min being zero
|
||||
return (y - min) / (max - min) * scaleFactor
|
||||
}
|
||||
}
|
||||
|
||||
var listPaymentsCommand = cli.Command{
|
||||
Name: "listpayments",
|
||||
Category: "Payments",
|
||||
|
@ -184,24 +184,24 @@ type resolverType uint8
|
||||
const (
|
||||
// resolverTimeout is the type of a resolver that's tasked with
|
||||
// resolving an outgoing HTLC that is very close to timing out.
|
||||
resolverTimeout = 0
|
||||
resolverTimeout resolverType = 0
|
||||
|
||||
// resolverSuccess is the type of a resolver that's tasked with
|
||||
// resolving an incoming HTLC that we already know the preimage of.
|
||||
resolverSuccess = 1
|
||||
resolverSuccess resolverType = 1
|
||||
|
||||
// resolverOutgoingContest is the type of a resolver that's tasked with
|
||||
// resolving an outgoing HTLC that hasn't yet timed out.
|
||||
resolverOutgoingContest = 2
|
||||
resolverOutgoingContest resolverType = 2
|
||||
|
||||
// resolverIncomingContest is the type of a resolver that's tasked with
|
||||
// resolving an incoming HTLC that we don't yet know the preimage to.
|
||||
resolverIncomingContest = 3
|
||||
resolverIncomingContest resolverType = 3
|
||||
|
||||
// resolverUnilateralSweep is the type of resolver that's tasked with
|
||||
// sweeping out direct commitment output form the remote party's
|
||||
// commitment transaction.
|
||||
resolverUnilateralSweep = 4
|
||||
resolverUnilateralSweep resolverType = 4
|
||||
)
|
||||
|
||||
// resolverIDLen is the size of the resolver ID key. This is 36 bytes as we get
|
||||
@ -366,7 +366,7 @@ func (b *boltArbitratorLog) writeResolver(contractBucket *bbolt.Bucket,
|
||||
// this byte, we can later properly deserialize the resolver properly.
|
||||
var (
|
||||
buf bytes.Buffer
|
||||
rType uint8
|
||||
rType resolverType
|
||||
)
|
||||
switch res.(type) {
|
||||
case *htlcTimeoutResolver:
|
||||
@ -461,7 +461,7 @@ func (b *boltArbitratorLog) FetchUnresolvedContracts() ([]ContractResolver, erro
|
||||
// We'll snip off the first byte of the raw resolver
|
||||
// bytes in order to extract what type of resolver
|
||||
// we're about to encode.
|
||||
resType := resBytes[0]
|
||||
resType := resolverType(resBytes[0])
|
||||
|
||||
// Then we'll create a reader using the remaining
|
||||
// bytes.
|
||||
|
@ -23,7 +23,6 @@ type mockArbitratorLog struct {
|
||||
failCommit bool
|
||||
failCommitState ArbitratorState
|
||||
resolutions *ContractResolutions
|
||||
chainActions ChainActionMap
|
||||
resolvers map[ContractResolver]struct{}
|
||||
|
||||
commitSet *CommitSet
|
||||
|
@ -43,10 +43,6 @@ var (
|
||||
_, _ = testSig.R.SetString("63724406601629180062774974542967536251589935445068131219452686511677818569431", 10)
|
||||
_, _ = testSig.S.SetString("18801056069249825825291287104931333862866033135609736119018462340006816851118", 10)
|
||||
|
||||
inputStr = "147caa76786596590baa4e98f5d9f48b86c7765e489f7a6ff3360fe5c674360b"
|
||||
sha, _ = chainhash.NewHashFromStr(inputStr)
|
||||
outpoint = wire.NewOutPoint(sha, 0)
|
||||
|
||||
bitcoinKeyPriv1, _ = btcec.NewPrivateKey(btcec.S256())
|
||||
bitcoinKeyPub1 = bitcoinKeyPriv1.PubKey()
|
||||
|
||||
@ -59,10 +55,9 @@ var (
|
||||
nodeKeyPriv2, _ = btcec.NewPrivateKey(btcec.S256())
|
||||
nodeKeyPub2 = nodeKeyPriv2.PubKey()
|
||||
|
||||
trickleDelay = time.Millisecond * 100
|
||||
retransmitDelay = time.Hour * 1
|
||||
proofMatureDelta uint32
|
||||
maxBtcFundingAmount = btcutil.Amount(1<<62) - 1
|
||||
trickleDelay = time.Millisecond * 100
|
||||
retransmitDelay = time.Hour * 1
|
||||
proofMatureDelta uint32
|
||||
)
|
||||
|
||||
// makeTestDB creates a new instance of the ChannelDB for testing purposes. A
|
||||
|
@ -116,10 +116,6 @@ type SyncManager struct {
|
||||
|
||||
cfg SyncManagerCfg
|
||||
|
||||
// historicalSync allows us to perform an initial historical sync only
|
||||
// _once_ with a peer during the SyncManager's startup.
|
||||
historicalSync sync.Once
|
||||
|
||||
// newSyncers is a channel we'll use to process requests to create
|
||||
// GossipSyncers for newly connected peers.
|
||||
newSyncers chan *newSyncer
|
||||
|
@ -187,10 +187,6 @@ type gossipSyncerCfg struct {
|
||||
// in compressed format.
|
||||
peerPub [33]byte
|
||||
|
||||
// syncChanUpdates is a bool that indicates if we should request a
|
||||
// continual channel update stream or not.
|
||||
syncChanUpdates bool
|
||||
|
||||
// channelSeries is the primary interface that we'll use to generate
|
||||
// our queries and respond to the queries of the remote peer.
|
||||
channelSeries ChannelGraphTimeSeries
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
const (
|
||||
defaultEncoding = lnwire.EncodingSortedPlain
|
||||
latestKnownHeight = 1337
|
||||
startHeight = latestKnownHeight - chanRangeQueryBuffer
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -109,16 +109,6 @@ func CreateChanAnnouncement(chanProof *channeldb.ChannelAuthProof,
|
||||
return chanAnn, edge1Ann, edge2Ann, nil
|
||||
}
|
||||
|
||||
// copyPubKey performs a copy of the target public key, setting a fresh curve
|
||||
// parameter during the process.
|
||||
func copyPubKey(pub *btcec.PublicKey) *btcec.PublicKey {
|
||||
return &btcec.PublicKey{
|
||||
Curve: btcec.S256(),
|
||||
X: pub.X,
|
||||
Y: pub.Y,
|
||||
}
|
||||
}
|
||||
|
||||
// SignAnnouncement is a helper function which is used to sign any outgoing
|
||||
// channel node node announcement messages.
|
||||
func SignAnnouncement(signer lnwallet.MessageSigner, pubKey *btcec.PublicKey,
|
||||
|
@ -123,15 +123,6 @@ func (r *reservationWithCtx) isLocked() bool {
|
||||
return r.lastUpdated.IsZero()
|
||||
}
|
||||
|
||||
// lock locks the reservation from zombie pruning by setting its timestamp to the
|
||||
// zero value.
|
||||
func (r *reservationWithCtx) lock() {
|
||||
r.updateMtx.Lock()
|
||||
defer r.updateMtx.Unlock()
|
||||
|
||||
r.lastUpdated = time.Time{}
|
||||
}
|
||||
|
||||
// updateTimestamp updates the reservation's timestamp with the current time.
|
||||
func (r *reservationWithCtx) updateTimestamp() {
|
||||
r.updateMtx.Lock()
|
||||
@ -2506,14 +2497,6 @@ func (f *fundingManager) handleFundingLocked(fmsg *fundingLockedMsg) {
|
||||
}
|
||||
}
|
||||
|
||||
// channelProof is one half of the proof necessary to create an authenticated
|
||||
// announcement on the network. The two signatures individually sign a
|
||||
// statement of the existence of a channel.
|
||||
type channelProof struct {
|
||||
nodeSig *btcec.Signature
|
||||
bitcoinSig *btcec.Signature
|
||||
}
|
||||
|
||||
// chanAnnouncement encapsulates the two authenticated announcements that we
|
||||
// send out to the network after a new channel has been created locally.
|
||||
type chanAnnouncement struct {
|
||||
|
@ -49,8 +49,6 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
privPass = []byte("dummy-pass")
|
||||
|
||||
// Use hard-coded keys for Alice and Bob, the two FundingManagers that
|
||||
// we will test the interaction between.
|
||||
alicePrivKeyBytes = [32]byte{
|
||||
|
@ -550,18 +550,6 @@ func assertHasKeystone(t *testing.T, cm htlcswitch.CircuitMap,
|
||||
}
|
||||
}
|
||||
|
||||
// assertDoesNotHaveKeystone tests that the circuit map does not contain a
|
||||
// circuit for the provided outgoing circuit key.
|
||||
func assertDoesNotHaveKeystone(t *testing.T, cm htlcswitch.CircuitMap,
|
||||
outKey htlcswitch.CircuitKey) {
|
||||
|
||||
circuit := cm.LookupOpenCircuit(outKey)
|
||||
if circuit != nil {
|
||||
t.Fatalf("expected no circuit for keystone %s, found %v",
|
||||
outKey, circuit)
|
||||
}
|
||||
}
|
||||
|
||||
// assertHasCircuitForHash tests that the provided circuit appears in the list
|
||||
// of circuits for the given hash.
|
||||
func assertHasCircuitForHash(t *testing.T, cm htlcswitch.CircuitMap, hash [32]byte,
|
||||
@ -619,17 +607,6 @@ func equalIgnoreLFD(c, c2 *htlcswitch.PaymentCircuit) bool {
|
||||
return isEqual
|
||||
}
|
||||
|
||||
// assertDoesNotHaveCircuit queries the circuit map using the circuit's
|
||||
// incoming circuit key, and fails if it is found.
|
||||
func assertDoesNotHaveCircuit(t *testing.T, cm htlcswitch.CircuitMap,
|
||||
c *htlcswitch.PaymentCircuit) {
|
||||
|
||||
c2 := cm.LookupCircuit(c.Incoming)
|
||||
if c2 != nil {
|
||||
t.Fatalf("expected no circuit for %v, got %v", c, c2)
|
||||
}
|
||||
}
|
||||
|
||||
// makeCircuitDB initializes a new test channeldb for testing the persistence of
|
||||
// the circuit map. If an empty string is provided as a path, a temp directory
|
||||
// will be created.
|
||||
|
@ -321,10 +321,6 @@ type channelLink struct {
|
||||
// been processed because of the commitment transaction overflow.
|
||||
overflowQueue *packetQueue
|
||||
|
||||
// startMailBox directs whether or not to start the mailbox when
|
||||
// starting the link. It may have already been started by the switch.
|
||||
startMailBox bool
|
||||
|
||||
// mailBox is the main interface between the outside world and the
|
||||
// link. All incoming messages will be sent over this mailBox. Messages
|
||||
// include new updates from our connected peer, and new packets to be
|
||||
|
@ -1690,7 +1690,6 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) (
|
||||
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
||||
}
|
||||
|
||||
const startingHeight = 100
|
||||
aliceLink := NewChannelLink(aliceCfg, aliceLc.channel)
|
||||
start := func() error {
|
||||
return aliceSwitch.AddLink(aliceLink)
|
||||
@ -4035,10 +4034,6 @@ func TestChannelLinkAcceptOverpay(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// chanRestoreFunc is a method signature for functions that can reload both
|
||||
// endpoints of a link from their persistent storage engines.
|
||||
type chanRestoreFunc func() (*lnwallet.LightningChannel, *lnwallet.LightningChannel, error)
|
||||
|
||||
// persistentLinkHarness is used to control the lifecylce of a link and the
|
||||
// switch that operates it. It supports the ability to restart either the link
|
||||
// or both the link and the switch.
|
||||
@ -4256,7 +4251,6 @@ func (h *persistentLinkHarness) restartLink(
|
||||
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
||||
}
|
||||
|
||||
const startingHeight = 100
|
||||
aliceLink := NewChannelLink(aliceCfg, aliceChannel)
|
||||
if err := aliceSwitch.AddLink(aliceLink); err != nil {
|
||||
return nil, nil, nil, err
|
||||
@ -5394,7 +5388,6 @@ func TestChannelLinkFail(t *testing.T) {
|
||||
}
|
||||
|
||||
const chanAmt = btcutil.SatoshiPerBitcoin * 5
|
||||
const chanReserve = 0
|
||||
|
||||
// Execute each test case.
|
||||
for i, test := range testCases {
|
||||
|
@ -63,7 +63,6 @@ type memoryMailBox struct {
|
||||
stopped sync.Once
|
||||
|
||||
wireMessages *list.List
|
||||
wireHead *list.Element
|
||||
wireMtx sync.Mutex
|
||||
wireCond *sync.Cond
|
||||
|
||||
|
@ -128,8 +128,6 @@ type mockServer struct {
|
||||
name string
|
||||
messages chan lnwire.Message
|
||||
|
||||
errChan chan error
|
||||
|
||||
id [33]byte
|
||||
htlcSwitch *Switch
|
||||
|
||||
@ -625,8 +623,6 @@ type mockChannelLink struct {
|
||||
|
||||
peer lnpeer.Peer
|
||||
|
||||
startMailBox bool
|
||||
|
||||
mailBox MailBox
|
||||
|
||||
packets chan *htlcPacket
|
||||
|
@ -21,14 +21,6 @@ type htlcPacket struct {
|
||||
// on the incoming channel.
|
||||
incomingHTLCID uint64
|
||||
|
||||
// incomingHtlcAmt is the value of the *incoming* HTLC. This will be
|
||||
// set by the link when it receives an incoming HTLC to be forwarded
|
||||
// through the switch. Then the outgoing link will use this once it
|
||||
// creates a full circuit add. This allows us to properly populate the
|
||||
// forwarding event for this circuit/packet in the case the payment
|
||||
// circuit is successful.
|
||||
incomingHtlcAmt lnwire.MilliSatoshi
|
||||
|
||||
// outgoingHTLCID is the ID of the HTLC that we offered to the peer on the
|
||||
// outgoing channel.
|
||||
outgoingHTLCID uint64
|
||||
|
@ -2,7 +2,6 @@ package htlcswitch
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
@ -66,10 +65,6 @@ var (
|
||||
// ErrUnreadableFailureMessage is returned when the failure message
|
||||
// cannot be decrypted.
|
||||
ErrUnreadableFailureMessage = errors.New("unreadable failure message")
|
||||
|
||||
// zeroPreimage is the empty preimage which is returned when we have
|
||||
// some errors.
|
||||
zeroPreimage [sha256.Size]byte
|
||||
)
|
||||
|
||||
// plexPacket encapsulates switch packet and adds error channel to receive
|
||||
@ -258,10 +253,6 @@ type Switch struct {
|
||||
// messages will be sent over.
|
||||
resolutionMsgs chan *resolutionMsg
|
||||
|
||||
// linkControl is a channel used to propagate add/remove/get htlc
|
||||
// switch handler commands.
|
||||
linkControl chan interface{}
|
||||
|
||||
// pendingFwdingEvents is the set of forwarding events which have been
|
||||
// collected during the current interval, but hasn't yet been written
|
||||
// to the forwarding log.
|
||||
@ -2225,18 +2216,6 @@ func (s *Switch) deleteCircuits(inKeys ...CircuitKey) error {
|
||||
return s.circuits.DeleteCircuits(inKeys...)
|
||||
}
|
||||
|
||||
// lookupCircuit queries the in memory representation of the circuit map to
|
||||
// retrieve a particular circuit.
|
||||
func (s *Switch) lookupCircuit(inKey CircuitKey) *PaymentCircuit {
|
||||
return s.circuits.LookupCircuit(inKey)
|
||||
}
|
||||
|
||||
// lookupOpenCircuit queries the in-memory representation of the circuit map for a
|
||||
// circuit whose outgoing circuit key matches outKey.
|
||||
func (s *Switch) lookupOpenCircuit(outKey CircuitKey) *PaymentCircuit {
|
||||
return s.circuits.LookupOpenCircuit(outKey)
|
||||
}
|
||||
|
||||
// FlushForwardingEvents flushes out the set of pending forwarding events to
|
||||
// the persistent log. This will be used by the switch to periodically flush
|
||||
// out the set of forwarding events to disk. External callers can also use this
|
||||
|
@ -41,15 +41,7 @@ var (
|
||||
bobPrivKey = []byte("bob priv key")
|
||||
carolPrivKey = []byte("carol priv key")
|
||||
|
||||
testPrivKey = []byte{
|
||||
0x81, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
|
||||
0x63, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
|
||||
0xd, 0xe7, 0x95, 0xe4, 0xb7, 0x25, 0xb8, 0x4d,
|
||||
0x1e, 0xb, 0x4c, 0xfd, 0x9e, 0xc5, 0x8c, 0xe9,
|
||||
}
|
||||
|
||||
_, testPubKey = btcec.PrivKeyFromBytes(btcec.S256(), testPrivKey)
|
||||
testSig = &btcec.Signature{
|
||||
testSig = &btcec.Signature{
|
||||
R: new(big.Int),
|
||||
S: new(big.Int),
|
||||
}
|
||||
|
@ -27,10 +27,6 @@ var (
|
||||
|
||||
// errNoUpdate is returned when no invoice updated is required.
|
||||
errNoUpdate = errors.New("no update needed")
|
||||
|
||||
// errReplayedHtlc is returned if the htlc is already recorded on the
|
||||
// invoice.
|
||||
errReplayedHtlc = errors.New("replayed htlc")
|
||||
)
|
||||
|
||||
// HodlEvent describes how an htlc should be resolved. If HodlEvent.Preimage is
|
||||
|
@ -23,8 +23,6 @@ var (
|
||||
|
||||
testHtlcExpiry = uint32(5)
|
||||
|
||||
testInvoiceCltvDelta = uint32(4)
|
||||
|
||||
testFinalCltvRejectDelta = int32(4)
|
||||
|
||||
testCurrentHeight = int32(1)
|
||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -40,6 +40,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -40,6 +40,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
@ -69,9 +69,6 @@ var (
|
||||
// RPC server allows external callers to access the status of the invoices
|
||||
// currently active within lnd, as well as configuring it at runtime.
|
||||
type Server struct {
|
||||
started int32 // To be used atomically.
|
||||
shutdown int32 // To be used atomically.
|
||||
|
||||
quit chan struct{}
|
||||
|
||||
cfg *Config
|
||||
|
@ -33,7 +33,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -43,6 +43,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -40,6 +40,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -40,6 +40,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -42,6 +42,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -43,6 +43,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
|
||||
"github.com/btcsuite/btcwallet/chain"
|
||||
"github.com/btcsuite/btcwallet/wallet"
|
||||
@ -19,25 +18,11 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
lnwalletHomeDir = btcutil.AppDataDir("lnwallet", false)
|
||||
defaultDataDir = lnwalletHomeDir
|
||||
|
||||
defaultLogFilename = "lnwallet.log"
|
||||
defaultLogDirname = "logs"
|
||||
defaultLogDir = filepath.Join(lnwalletHomeDir, defaultLogDirname)
|
||||
|
||||
btcdHomeDir = btcutil.AppDataDir("btcd", false)
|
||||
btcdHomedirCAFile = filepath.Join(btcdHomeDir, "rpc.cert")
|
||||
defaultRPCKeyFile = filepath.Join(lnwalletHomeDir, "rpc.key")
|
||||
defaultRPCCertFile = filepath.Join(lnwalletHomeDir, "rpc.cert")
|
||||
|
||||
// defaultPubPassphrase is the default public wallet passphrase which is
|
||||
// used when the user indicates they do not want additional protection
|
||||
// provided by having all public data in the wallet encrypted by a
|
||||
// passphrase only known to them.
|
||||
defaultPubPassphrase = []byte("public")
|
||||
|
||||
walletDbName = "lnwallet.db"
|
||||
)
|
||||
|
||||
// Config is a struct which houses configuration parameters which modify the
|
||||
|
@ -109,7 +109,7 @@ type channelState uint8
|
||||
const (
|
||||
// channelPending indicates this channel is still going through the
|
||||
// funding workflow, and isn't yet open.
|
||||
channelPending channelState = iota
|
||||
channelPending channelState = iota // nolint: unused
|
||||
|
||||
// channelOpen represents an open, active channel capable of
|
||||
// sending/receiving HTLCs.
|
||||
@ -130,7 +130,7 @@ const (
|
||||
|
||||
// channelPendingPayment indicates that there a currently outstanding
|
||||
// HTLCs within the channel.
|
||||
channelPendingPayment
|
||||
channelPendingPayment // nolint:unused
|
||||
)
|
||||
|
||||
// PaymentHash represents the sha256 of a random value. This hash is used to
|
||||
@ -1031,10 +1031,6 @@ type commitmentChain struct {
|
||||
// Once a commitment transaction is revoked, the tail is incremented,
|
||||
// freeing up the revocation window for new commitments.
|
||||
commitments *list.List
|
||||
|
||||
// startingHeight is the starting height of this commitment chain on a
|
||||
// session basis.
|
||||
startingHeight uint64
|
||||
}
|
||||
|
||||
// newCommitmentChain creates a new commitment chain.
|
||||
@ -1296,8 +1292,6 @@ type LightningChannel struct {
|
||||
// the commitment transaction that spends the multi-sig output.
|
||||
signDesc *input.SignDescriptor
|
||||
|
||||
channelEvents chainntnfs.ChainNotifier
|
||||
|
||||
status channelState
|
||||
|
||||
// ChanPoint is the funding outpoint of this channel.
|
||||
|
@ -1311,7 +1311,6 @@ func TestStateUpdatePersistence(t *testing.T) {
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
const numHtlcs = 4
|
||||
htlcAmt := lnwire.NewMSatFromSatoshis(5000)
|
||||
|
||||
var fakeOnionBlob [lnwire.OnionPacketSize]byte
|
||||
|
@ -43,16 +43,6 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
privPass = []byte("private-test")
|
||||
|
||||
// For simplicity a single priv key controls all of our test outputs.
|
||||
testWalletPrivKey = []byte{
|
||||
0x2b, 0xd8, 0x06, 0xc9, 0x7f, 0x0e, 0x00, 0xaf,
|
||||
0x1a, 0x1f, 0xc3, 0x32, 0x8f, 0xa7, 0x63, 0xa9,
|
||||
0x26, 0x97, 0x23, 0xc8, 0xdb, 0x8f, 0xac, 0x4f,
|
||||
0x93, 0xaf, 0x71, 0xdb, 0x18, 0x6d, 0x6e, 0x90,
|
||||
}
|
||||
|
||||
bobsPrivKey = []byte{
|
||||
0x81, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
|
||||
0x63, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
|
||||
@ -113,22 +103,6 @@ func assertProperBalance(t *testing.T, lw *lnwallet.LightningWallet,
|
||||
}
|
||||
}
|
||||
|
||||
func assertChannelOpen(t *testing.T, miner *rpctest.Harness, numConfs uint32,
|
||||
c <-chan *lnwallet.LightningChannel) *lnwallet.LightningChannel {
|
||||
// Mine a single block. After this block is mined, the channel should
|
||||
// be considered fully open.
|
||||
if _, err := miner.Node.Generate(1); err != nil {
|
||||
t.Fatalf("unable to generate block: %v", err)
|
||||
}
|
||||
select {
|
||||
case lnc := <-c:
|
||||
return lnc
|
||||
case <-time.After(time.Second * 5):
|
||||
t.Fatalf("channel never opened")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func assertReservationDeleted(res *lnwallet.ChannelReservation, t *testing.T) {
|
||||
if err := res.Cancel(); err == nil {
|
||||
t.Fatalf("reservation wasn't deleted from wallet")
|
||||
@ -253,20 +227,6 @@ func assertTxInWallet(t *testing.T, w *lnwallet.LightningWallet,
|
||||
t.Fatalf("transaction %v not found", txHash)
|
||||
}
|
||||
|
||||
// calcStaticFee calculates appropriate fees for commitment transactions. This
|
||||
// function provides a simple way to allow test balance assertions to take fee
|
||||
// calculations into account.
|
||||
// TODO(bvu): Refactor when dynamic fee estimation is added.
|
||||
func calcStaticFee(numHTLCs int) btcutil.Amount {
|
||||
const (
|
||||
commitWeight = btcutil.Amount(724)
|
||||
htlcWeight = 172
|
||||
feePerKw = btcutil.Amount(250/4) * 1000
|
||||
)
|
||||
return feePerKw * (commitWeight +
|
||||
btcutil.Amount(htlcWeight*numHTLCs)) / 1000
|
||||
}
|
||||
|
||||
func loadTestCredits(miner *rpctest.Harness, w *lnwallet.LightningWallet,
|
||||
numOutputs int, btcPerOutput float64) error {
|
||||
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
@ -17,14 +16,11 @@ import (
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/shachain"
|
||||
)
|
||||
|
||||
var (
|
||||
privPass = []byte("private-test")
|
||||
|
||||
// For simplicity a single priv key controls all of our test outputs.
|
||||
testWalletPrivKey = []byte{
|
||||
0x2b, 0xd8, 0x06, 0xc9, 0x7f, 0x0e, 0x00, 0xaf,
|
||||
@ -49,10 +45,6 @@ var (
|
||||
0x6a, 0x49, 0x18, 0x83, 0x31, 0x98, 0x47, 0x53,
|
||||
}
|
||||
|
||||
// The number of confirmations required to consider any created channel
|
||||
// open.
|
||||
numReqConfs = uint16(1)
|
||||
|
||||
// A serializable txn for testing funding txn.
|
||||
testTx = &wire.MsgTx{
|
||||
Version: 1,
|
||||
@ -382,43 +374,6 @@ func initRevocationWindows(chanA, chanB *LightningChannel) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type mockPreimageCache struct {
|
||||
sync.Mutex
|
||||
preimageMap map[lntypes.Hash]lntypes.Preimage
|
||||
}
|
||||
|
||||
func newMockPreimageCache() *mockPreimageCache {
|
||||
return &mockPreimageCache{
|
||||
preimageMap: make(map[lntypes.Hash]lntypes.Preimage),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mockPreimageCache) LookupPreimage(
|
||||
hash lntypes.Hash) (lntypes.Preimage, bool) {
|
||||
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
p, ok := m.preimageMap[hash]
|
||||
return p, ok
|
||||
}
|
||||
|
||||
func (m *mockPreimageCache) AddPreimages(preimages ...lntypes.Preimage) error {
|
||||
preimageCopies := make([]lntypes.Preimage, 0, len(preimages))
|
||||
for _, preimage := range preimages {
|
||||
preimageCopies = append(preimageCopies, preimage)
|
||||
}
|
||||
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
for _, preimage := range preimageCopies {
|
||||
m.preimageMap[preimage.Hash()] = preimage
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// pubkeyFromHex parses a Bitcoin public key from a hex encoded string.
|
||||
func pubkeyFromHex(keyHex string) (*btcec.PublicKey, error) {
|
||||
bytes, err := hex.DecodeString(keyHex)
|
||||
@ -439,25 +394,6 @@ func privkeyFromHex(keyHex string) (*btcec.PrivateKey, error) {
|
||||
|
||||
}
|
||||
|
||||
// pubkeyToHex serializes a Bitcoin public key to a hex encoded string.
|
||||
func pubkeyToHex(key *btcec.PublicKey) string {
|
||||
return hex.EncodeToString(key.SerializeCompressed())
|
||||
}
|
||||
|
||||
// privkeyFromHex serializes a Bitcoin private key to a hex encoded string.
|
||||
func privkeyToHex(key *btcec.PrivateKey) string {
|
||||
return hex.EncodeToString(key.Serialize())
|
||||
}
|
||||
|
||||
// signatureFromHex parses a Bitcoin signature from a hex encoded string.
|
||||
func signatureFromHex(sigHex string) (*btcec.Signature, error) {
|
||||
bytes, err := hex.DecodeString(sigHex)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return btcec.ParseSignature(bytes, btcec.S256())
|
||||
}
|
||||
|
||||
// blockFromHex parses a full Bitcoin block from a hex encoded string.
|
||||
func blockFromHex(blockHex string) (*btcutil.Block, error) {
|
||||
bytes, err := hex.DecodeString(blockHex)
|
||||
|
@ -222,11 +222,10 @@ func newTestContext() (tc *testContext, err error) {
|
||||
}
|
||||
|
||||
htlcData := []struct {
|
||||
incoming bool
|
||||
amount lnwire.MilliSatoshi
|
||||
expiry uint32
|
||||
preimage string
|
||||
paymentHash PaymentHash
|
||||
incoming bool
|
||||
amount lnwire.MilliSatoshi
|
||||
expiry uint32
|
||||
preimage string
|
||||
}{
|
||||
{
|
||||
incoming: true,
|
||||
|
@ -253,10 +253,6 @@ type LightningWallet struct {
|
||||
// keys, revocation keys, etc.
|
||||
keychain.SecretKeyRing
|
||||
|
||||
// This mutex is to be held when generating external keys to be used as
|
||||
// multi-sig, and commitment keys within the channel.
|
||||
keyGenMtx sync.RWMutex
|
||||
|
||||
// This mutex MUST be held when performing coin selection in order to
|
||||
// avoid inadvertently creating multiple funding transaction which
|
||||
// double spend inputs across each other.
|
||||
@ -956,9 +952,6 @@ func (l *LightningWallet) handleSingleContribution(req *addSingleContributionMsg
|
||||
// pertaining to the exact location in the main chain in-which the transaction
|
||||
// was confirmed.
|
||||
type openChanDetails struct {
|
||||
channel *LightningChannel
|
||||
blockHeight uint32
|
||||
txIndex uint32
|
||||
}
|
||||
|
||||
// handleFundingCounterPartySigs is the final step in the channel reservation
|
||||
|
@ -23,13 +23,6 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
revHash = [32]byte{
|
||||
0xb7, 0x94, 0x38, 0x5f, 0x2d, 0x1e, 0xf7, 0xab,
|
||||
0x4d, 0x92, 0x73, 0xd1, 0x90, 0x63, 0x81, 0xb4,
|
||||
0x4f, 0x2f, 0x6f, 0x25, 0x88, 0xa3, 0xef, 0xb9,
|
||||
0x6a, 0x49, 0x18, 0x83, 0x31, 0x98, 0x47, 0x53,
|
||||
}
|
||||
|
||||
shaHash1Bytes, _ = hex.DecodeString("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
|
||||
shaHash1, _ = chainhash.NewHash(shaHash1Bytes)
|
||||
outpoint1 = wire.NewOutPoint(shaHash1, 0)
|
||||
|
@ -10,11 +10,6 @@ import (
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
var (
|
||||
startPort uint16 = 1024
|
||||
endPort uint16 = 49151
|
||||
)
|
||||
|
||||
// ErrUnknownAddrType is an error returned if we encounter an unknown address type
|
||||
// when parsing addresses.
|
||||
type ErrUnknownAddrType struct {
|
||||
|
32
mock.go
32
mock.go
@ -16,7 +16,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
)
|
||||
|
||||
@ -228,7 +227,6 @@ func (*mockChainIO) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error)
|
||||
// interaction with the bitcoin network.
|
||||
type mockWalletController struct {
|
||||
rootKey *btcec.PrivateKey
|
||||
prevAddres btcutil.Address
|
||||
publishedTransactions chan *wire.MsgTx
|
||||
index uint32
|
||||
utxos []*lnwallet.Utxo
|
||||
@ -355,33 +353,3 @@ func (m *mockSecretKeyRing) ScalarMult(keyDesc keychain.KeyDescriptor,
|
||||
pubKey *btcec.PublicKey) ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type mockPreimageCache struct {
|
||||
sync.Mutex
|
||||
preimageMap map[lntypes.Hash]lntypes.Preimage
|
||||
}
|
||||
|
||||
func newMockPreimageCache() *mockPreimageCache {
|
||||
return &mockPreimageCache{
|
||||
preimageMap: make(map[lntypes.Hash]lntypes.Preimage),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mockPreimageCache) LookupPreimage(hash lntypes.Hash) (lntypes.Preimage, bool) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
p, ok := m.preimageMap[hash]
|
||||
return p, ok
|
||||
}
|
||||
|
||||
func (m *mockPreimageCache) AddPreimages(preimages ...lntypes.Preimage) error {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
for _, preimage := range preimages {
|
||||
m.preimageMap[preimage.Hash()] = preimage
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -40,6 +40,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
@ -111,7 +111,6 @@ func createEdgePolicies(t *testing.T, channel *channeldb.OpenChannel,
|
||||
}
|
||||
|
||||
type mockGraph struct {
|
||||
pubKey *btcec.PublicKey
|
||||
mu sync.Mutex
|
||||
channels []*channeldb.OpenChannel
|
||||
chanInfos map[wire.OutPoint]*channeldb.ChannelEdgeInfo
|
||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -40,6 +40,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
11
peer.go
11
peer.go
@ -30,10 +30,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/ticker"
|
||||
)
|
||||
|
||||
var (
|
||||
numNodes int32
|
||||
)
|
||||
|
||||
const (
|
||||
// pingInterval is the interval at which ping messages are sent.
|
||||
pingInterval = 1 * time.Minute
|
||||
@ -82,12 +78,6 @@ type closeMsg struct {
|
||||
msg lnwire.Message
|
||||
}
|
||||
|
||||
// chanSnapshotReq is a message sent by outside subsystems to a peer in order
|
||||
// to gain a snapshot of the peer's currently active channels.
|
||||
type chanSnapshotReq struct {
|
||||
resp chan []*channeldb.ChannelSnapshot
|
||||
}
|
||||
|
||||
// pendingUpdate describes the pending state of a closing channel.
|
||||
type pendingUpdate struct {
|
||||
Txid []byte
|
||||
@ -717,7 +707,6 @@ type msgStream struct {
|
||||
|
||||
mtx sync.Mutex
|
||||
|
||||
bufSize uint32
|
||||
producerSema chan struct{}
|
||||
|
||||
wg sync.WaitGroup
|
||||
|
@ -437,7 +437,6 @@ func (b *BtcdFilteredChainView) chainFilterer() {
|
||||
type filterUpdate struct {
|
||||
newUtxos []wire.OutPoint
|
||||
updateHeight uint32
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
// UpdateFilter updates the UTXO filter which is to be consulted when creating
|
||||
|
@ -3,7 +3,6 @@ package routing
|
||||
import (
|
||||
"container/heap"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
@ -120,62 +119,3 @@ func (d *distanceHeap) PushOrFix(dist nodeWithDist) {
|
||||
// Call heap.Fix to reorder the heap.
|
||||
heap.Fix(d, index)
|
||||
}
|
||||
|
||||
// path represents an ordered set of edges which forms an available path from a
|
||||
// given source node to our destination. During the process of computing the
|
||||
// KSP's from a source to destination, several path swill be considered in the
|
||||
// process.
|
||||
type path struct {
|
||||
// dist is the distance from the source node to the destination node
|
||||
// that the path requires.
|
||||
dist int
|
||||
|
||||
// hops is an ordered list of edges that comprises a potential payment
|
||||
// path.
|
||||
hops []*channeldb.ChannelEdgePolicy
|
||||
}
|
||||
|
||||
// pathHeap is a min-heap that stores potential paths to be considered within
|
||||
// our KSP implementation. The heap sorts paths according to their cumulative
|
||||
// distance from a given source.
|
||||
type pathHeap struct {
|
||||
paths []path
|
||||
}
|
||||
|
||||
// Len returns the number of nodes in the priority queue.
|
||||
//
|
||||
// NOTE: This is part of the heap.Interface implementation.
|
||||
func (p *pathHeap) Len() int { return len(p.paths) }
|
||||
|
||||
// Less returns whether the item in the priority queue with index i should sort
|
||||
// before the item with index j.
|
||||
//
|
||||
// NOTE: This is part of the heap.Interface implementation.
|
||||
func (p *pathHeap) Less(i, j int) bool {
|
||||
return p.paths[i].dist < p.paths[j].dist
|
||||
}
|
||||
|
||||
// Swap swaps the nodes at the passed indices in the priority queue.
|
||||
//
|
||||
// NOTE: This is part of the heap.Interface implementation.
|
||||
func (p *pathHeap) Swap(i, j int) {
|
||||
p.paths[i], p.paths[j] = p.paths[j], p.paths[i]
|
||||
}
|
||||
|
||||
// Push pushes the passed item onto the priority queue.
|
||||
//
|
||||
// NOTE: This is part of the heap.Interface implementation.
|
||||
func (p *pathHeap) Push(x interface{}) {
|
||||
p.paths = append(p.paths, x.(path))
|
||||
}
|
||||
|
||||
// Pop removes the highest priority item (according to Less) from the priority
|
||||
// queue and returns it.
|
||||
//
|
||||
// NOTE: This is part of the heap.Interface implementation.
|
||||
func (p *pathHeap) Pop() interface{} {
|
||||
n := len(p.paths)
|
||||
x := p.paths[n-1]
|
||||
p.paths = p.paths[0 : n-1]
|
||||
return x
|
||||
}
|
||||
|
@ -125,7 +125,6 @@ type mockChain struct {
|
||||
utxos map[wire.OutPoint]wire.TxOut
|
||||
|
||||
bestHeight int32
|
||||
bestHash *chainhash.Hash
|
||||
|
||||
sync.RWMutex
|
||||
}
|
||||
|
@ -75,22 +75,6 @@ func computeFee(amt lnwire.MilliSatoshi,
|
||||
return edge.FeeBaseMSat + (amt*edge.FeeProportionalMillionths)/1000000
|
||||
}
|
||||
|
||||
// isSamePath returns true if path1 and path2 travel through the exact same
|
||||
// edges, and false otherwise.
|
||||
func isSamePath(path1, path2 []*channeldb.ChannelEdgePolicy) bool {
|
||||
if len(path1) != len(path2) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i := 0; i < len(path1); i++ {
|
||||
if path1[i].ChannelID != path2[i].ChannelID {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// newRoute returns a fully valid route between the source and target that's
|
||||
// capable of supporting a payment of `amtToSend` after fees are fully
|
||||
// computed. If the route is too long, or the selected path cannot support the
|
||||
|
@ -324,21 +324,6 @@ type testChannelEnd struct {
|
||||
*testChannelPolicy
|
||||
}
|
||||
|
||||
func defaultTestChannelEnd(alias string, capacity btcutil.Amount) *testChannelEnd {
|
||||
return &testChannelEnd{
|
||||
Alias: alias,
|
||||
testChannelPolicy: &testChannelPolicy{
|
||||
Expiry: 144,
|
||||
MinHTLC: lnwire.MilliSatoshi(1000),
|
||||
MaxHTLC: lnwire.NewMSatFromSatoshis(capacity),
|
||||
FeeBaseMsat: lnwire.MilliSatoshi(1000),
|
||||
FeeRate: lnwire.MilliSatoshi(1),
|
||||
LastUpdate: testTime,
|
||||
Disabled: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func symmetricTestChannel(alias1 string, alias2 string, capacity btcutil.Amount,
|
||||
policy *testChannelPolicy, chanID ...uint64) *testChannel {
|
||||
|
||||
@ -1675,13 +1660,6 @@ func TestPathFindSpecExample(t *testing.T) {
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
const (
|
||||
aliceFinalCLTV = 10
|
||||
bobFinalCLTV = 20
|
||||
carolFinalCLTV = 30
|
||||
daveFinalCLTV = 40
|
||||
)
|
||||
|
||||
// We'll first exercise the scenario of a direct payment from Bob to
|
||||
// Carol, so we set "B" as the source node so path finding starts from
|
||||
// Bob.
|
||||
|
@ -137,9 +137,3 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
|
||||
|
||||
return route, err
|
||||
}
|
||||
|
||||
// nodeChannel is a combination of the node pubkey and one of its channels.
|
||||
type nodeChannel struct {
|
||||
node route.Vertex
|
||||
channel uint64
|
||||
}
|
||||
|
@ -295,25 +295,6 @@ type Config struct {
|
||||
PathFindingConfig PathFindingConfig
|
||||
}
|
||||
|
||||
// routeTuple is an entry within the ChannelRouter's route cache. We cache
|
||||
// prospective routes based on first the destination, and then the target
|
||||
// amount. We required the target amount as that will influence the available
|
||||
// set of paths for a payment.
|
||||
type routeTuple struct {
|
||||
amt lnwire.MilliSatoshi
|
||||
dest [33]byte
|
||||
}
|
||||
|
||||
// newRouteTuple creates a new route tuple from the target and amount.
|
||||
func newRouteTuple(amt lnwire.MilliSatoshi, dest []byte) routeTuple {
|
||||
r := routeTuple{
|
||||
amt: amt,
|
||||
}
|
||||
copy(r.dest[:], dest)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// EdgeLocator is a struct used to identify a specific edge.
|
||||
type EdgeLocator struct {
|
||||
// ChannelID is the channel of this edge.
|
||||
@ -325,31 +306,6 @@ type EdgeLocator struct {
|
||||
Direction uint8
|
||||
}
|
||||
|
||||
// newEdgeLocatorByPubkeys returns an edgeLocator based on its end point
|
||||
// pubkeys.
|
||||
func newEdgeLocatorByPubkeys(channelID uint64, fromNode, toNode *route.Vertex) *EdgeLocator {
|
||||
// Determine direction based on lexicographical ordering of both
|
||||
// pubkeys.
|
||||
var direction uint8
|
||||
if bytes.Compare(fromNode[:], toNode[:]) == 1 {
|
||||
direction = 1
|
||||
}
|
||||
|
||||
return &EdgeLocator{
|
||||
ChannelID: channelID,
|
||||
Direction: direction,
|
||||
}
|
||||
}
|
||||
|
||||
// newEdgeLocator extracts an edgeLocator based for a full edge policy
|
||||
// structure.
|
||||
func newEdgeLocator(edge *channeldb.ChannelEdgePolicy) *EdgeLocator {
|
||||
return &EdgeLocator{
|
||||
ChannelID: edge.ChannelID,
|
||||
Direction: uint8(edge.ChannelFlags & lnwire.ChanUpdateDirection),
|
||||
}
|
||||
}
|
||||
|
||||
// String returns a human readable version of the edgeLocator values.
|
||||
func (e *EdgeLocator) String() string {
|
||||
return fmt.Sprintf("%v:%v", e.ChannelID, e.Direction)
|
||||
|
@ -67,14 +67,6 @@ func (c *testCtx) RestartRouter() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func copyPubKey(pub *btcec.PublicKey) *btcec.PublicKey {
|
||||
return &btcec.PublicKey{
|
||||
Curve: btcec.S256(),
|
||||
X: pub.X,
|
||||
Y: pub.Y,
|
||||
}
|
||||
}
|
||||
|
||||
func createTestCtxFromGraphInstance(startingHeight uint32, graphInstance *testGraphInstance) (
|
||||
*testCtx, func(), error) {
|
||||
|
||||
|
@ -27,7 +27,6 @@ import (
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwallet/waddrmgr"
|
||||
"github.com/btcsuite/btcwallet/wallet/txauthor"
|
||||
"github.com/coreos/bbolt"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
@ -77,8 +76,6 @@ var (
|
||||
// It is set to the value under the Bitcoin chain as default.
|
||||
MaxPaymentMSat = maxBtcPaymentMSat
|
||||
|
||||
defaultAccount uint32 = waddrmgr.DefaultAccountNum
|
||||
|
||||
// readPermissions is a slice of all entities that allow read
|
||||
// permissions for authorization purposes, all lowercase.
|
||||
readPermissions = []bakery.Op{
|
||||
@ -396,8 +393,6 @@ type rpcServer struct {
|
||||
|
||||
server *server
|
||||
|
||||
wg sync.WaitGroup
|
||||
|
||||
// subServers are a set of sub-RPC servers that use the same gRPC and
|
||||
// listening sockets as the main RPC server, but which maintain their
|
||||
// own independent service. This allows us to expose a set of
|
||||
|
@ -6,25 +6,6 @@ import (
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
)
|
||||
|
||||
// changeBit is a functio that function that flips a bit of the hash at a
|
||||
// particular bit-index. You should be aware that the bit flipping in this
|
||||
// function a bit strange, example:
|
||||
// hash: [0b00000000, 0b00000000, ... 0b00000000]
|
||||
// 0 1 ... 31
|
||||
//
|
||||
// byte: 0 0 0 0 0 0 0 0
|
||||
// 7 6 5 4 3 2 1 0
|
||||
//
|
||||
// By flipping the bit at 7 position you will flip the first bit in hash and by
|
||||
// flipping the bit at 8 position you will flip the 16 bit in hash.
|
||||
func changeBit(hash []byte, position uint8) []byte {
|
||||
byteNumber := position / 8
|
||||
bitNumber := position % 8
|
||||
|
||||
hash[byteNumber] ^= (1 << bitNumber)
|
||||
return hash
|
||||
}
|
||||
|
||||
// getBit return bit on index at position.
|
||||
func getBit(index index, position uint8) uint8 {
|
||||
return uint8((uint64(index) >> position) & 1)
|
||||
|
@ -286,25 +286,6 @@ func (ctx *sweeperTestContext) assertPendingInputs(inputs ...input.Input) {
|
||||
}
|
||||
}
|
||||
|
||||
// receiveSpendTx receives the transaction sent through the given resultChan.
|
||||
func receiveSpendTx(t *testing.T, resultChan chan Result) *wire.MsgTx {
|
||||
t.Helper()
|
||||
|
||||
var result Result
|
||||
select {
|
||||
case result = <-resultChan:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("no sweep result received")
|
||||
}
|
||||
|
||||
if result.Err != nil {
|
||||
t.Fatalf("expected successful spend, but received error "+
|
||||
"\"%v\" instead", result.Err)
|
||||
}
|
||||
|
||||
return result.Tx
|
||||
}
|
||||
|
||||
// assertTxSweepsInputs ensures that the transaction returned within the value
|
||||
// received from resultChan spends the given inputs.
|
||||
func assertTxSweepsInputs(t *testing.T, sweepTx *wire.MsgTx,
|
||||
|
@ -1019,21 +1019,6 @@ func (i *nurseryStoreInterceptor) RemoveChannel(chanPoint *wire.OutPoint) error
|
||||
return i.ns.RemoveChannel(chanPoint)
|
||||
}
|
||||
|
||||
type nurseryMockSigner struct {
|
||||
}
|
||||
|
||||
func (m *nurseryMockSigner) SignOutputRaw(tx *wire.MsgTx,
|
||||
signDesc *input.SignDescriptor) ([]byte, error) {
|
||||
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
func (m *nurseryMockSigner) ComputeInputScript(tx *wire.MsgTx,
|
||||
signDesc *input.SignDescriptor) (*input.Script, error) {
|
||||
|
||||
return &input.Script{}, nil
|
||||
}
|
||||
|
||||
type mockSweeper struct {
|
||||
lock sync.Mutex
|
||||
|
||||
|
@ -18,10 +18,6 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const (
|
||||
walletDbName = "wallet.db"
|
||||
)
|
||||
|
||||
var (
|
||||
testPassword = []byte("test-password")
|
||||
testSeed = []byte("test-seed-123456789")
|
||||
|
@ -34,7 +34,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -44,6 +44,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
@ -15,10 +15,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtwire"
|
||||
)
|
||||
|
||||
// retryInterval is the default duration we will wait between attempting to
|
||||
// connect back out to a tower if the prior state update failed.
|
||||
const retryInterval = 2 * time.Second
|
||||
|
||||
// reserveStatus is an enum that signals how full a particular session is.
|
||||
type reserveStatus uint8
|
||||
|
||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
||||
|
||||
// logClosure is used to provide a closure over expensive logging operations so
|
||||
// don't have to be performed when the logging level doesn't warrant it.
|
||||
type logClosure func() string
|
||||
type logClosure func() string // nolint:unused
|
||||
|
||||
// String invokes the underlying function and returns the result.
|
||||
func (c logClosure) String() string {
|
||||
@ -40,6 +40,6 @@ func (c logClosure) String() string {
|
||||
// newLogClosure returns a new closure over a function that returns a string
|
||||
// which itself provides a Stringer interface so that it can be used with the
|
||||
// logging system.
|
||||
func newLogClosure(c func() string) logClosure {
|
||||
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||
return logClosure(c)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user