multi: remove dead code
This commit is contained in:
parent
5d016f8c62
commit
3d7de2ad39
@ -102,10 +102,6 @@ const (
|
|||||||
// checkSumSize is the index within an enciphered cipher seed that
|
// checkSumSize is the index within an enciphered cipher seed that
|
||||||
// marks the start of the checksum.
|
// marks the start of the checksum.
|
||||||
checkSumOffset = EncipheredCipherSeedSize - checkSumSize
|
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 (
|
var (
|
||||||
|
@ -8,13 +8,6 @@ import (
|
|||||||
"testing/quick"
|
"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
|
// TestWeightedChoiceEmptyMap tests that passing in an empty slice of weights
|
||||||
// returns an error.
|
// returns an error.
|
||||||
func TestWeightedChoiceEmptyMap(t *testing.T) {
|
func TestWeightedChoiceEmptyMap(t *testing.T) {
|
||||||
@ -95,7 +88,6 @@ type nonNegative []float64
|
|||||||
// Generate generates a value of type nonNegative to be used during
|
// Generate generates a value of type nonNegative to be used during
|
||||||
// QuickTests.
|
// QuickTests.
|
||||||
func (nonNegative) Generate(rand *rand.Rand, size int) reflect.Value {
|
func (nonNegative) Generate(rand *rand.Rand, size int) reflect.Value {
|
||||||
const precision = 100
|
|
||||||
w := make([]float64, size)
|
w := make([]float64, size)
|
||||||
|
|
||||||
for i := range w {
|
for i := range w {
|
||||||
|
@ -74,10 +74,6 @@ var chanGraphs = []struct {
|
|||||||
// TestPrefAttachmentSelectEmptyGraph ensures that when passed an
|
// TestPrefAttachmentSelectEmptyGraph ensures that when passed an
|
||||||
// empty graph, the NodeSores function always returns a score of 0.
|
// empty graph, the NodeSores function always returns a score of 0.
|
||||||
func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
|
func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
|
||||||
const (
|
|
||||||
maxChanSize = btcutil.Amount(btcutil.SatoshiPerBitcoin)
|
|
||||||
)
|
|
||||||
|
|
||||||
prefAttach := NewPrefAttachment()
|
prefAttach := NewPrefAttachment()
|
||||||
|
|
||||||
// Create a random public key, which we will query to get a score for.
|
// 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
|
// TestPrefAttachmentSelectTwoVertexes ensures that when passed a
|
||||||
// graph with only two eligible vertexes, then both are given the same score,
|
// graph with only two eligible vertexes, then both are given the same score,
|
||||||
// and the funds are appropriately allocated across each peer.
|
// and the funds are appropriately allocated across each peer.
|
||||||
|
@ -1982,19 +1982,3 @@ func forceStateTransition(chanA, chanB *lnwallet.LightningChannel) error {
|
|||||||
|
|
||||||
return nil
|
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"
|
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:
|
// TODO(roasbeef): generalize struct below:
|
||||||
// * move chans to config
|
// * move chans to config
|
||||||
// * extract common code
|
// * extract common code
|
||||||
@ -166,13 +158,6 @@ func (b *BitcoindNotifier) Stop() error {
|
|||||||
return nil
|
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
|
// notificationDispatcher is the primary goroutine which handles client
|
||||||
// notification registrations, as well as notification dispatches.
|
// notification registrations, as well as notification dispatches.
|
||||||
func (b *BitcoindNotifier) notificationDispatcher() {
|
func (b *BitcoindNotifier) notificationDispatcher() {
|
||||||
|
@ -8,15 +8,6 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"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 (
|
var (
|
||||||
// spendHintBucket is the name of the bucket which houses the height
|
// spendHintBucket is the name of the bucket which houses the height
|
||||||
// hint for outpoints. Each height hint represents the earliest height
|
// hint for outpoints. Each height hint represents the earliest height
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"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/chainntnfs"
|
||||||
@ -33,7 +32,6 @@ var (
|
|||||||
0x86, 0xf4, 0xcb, 0xf9, 0x8e, 0xae, 0xd2, 0x21,
|
0x86, 0xf4, 0xcb, 0xf9, 0x8e, 0xae, 0xd2, 0x21,
|
||||||
0xb3, 0x0b, 0xd9, 0xa0, 0xb9, 0x28,
|
0xb3, 0x0b, 0xd9, 0xa0, 0xb9, 0x28,
|
||||||
}
|
}
|
||||||
testScript, _ = txscript.ParsePkScript(testRawScript)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type mockHintCache struct {
|
type mockHintCache struct {
|
||||||
|
@ -2298,23 +2298,6 @@ func serializeChannelCloseSummary(w io.Writer, cs *ChannelCloseSummary) error {
|
|||||||
return nil
|
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) {
|
func deserializeCloseChannelSummary(r io.Reader) (*ChannelCloseSummary, error) {
|
||||||
c := &ChannelCloseSummary{}
|
c := &ChannelCloseSummary{}
|
||||||
|
|
||||||
@ -2679,13 +2662,6 @@ func makeLogKey(updateNum uint64) [8]byte {
|
|||||||
return key
|
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,
|
func appendChannelLogEntry(log *bbolt.Bucket,
|
||||||
commit *ChannelCommitment) error {
|
commit *ChannelCommitment) error {
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec"
|
"github.com/btcsuite/btcd/btcec"
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
@ -23,23 +22,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
netParams = &chaincfg.TestNet3Params
|
|
||||||
|
|
||||||
key = [chainhash.HashSize]byte{
|
key = [chainhash.HashSize]byte{
|
||||||
0x81, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
|
0x81, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
|
||||||
0x68, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
|
0x68, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
|
||||||
0xd, 0xe7, 0x93, 0xe4, 0xb7, 0x25, 0xb8, 0x4d,
|
0xd, 0xe7, 0x93, 0xe4, 0xb7, 0x25, 0xb8, 0x4d,
|
||||||
0x1e, 0xb, 0x4c, 0xf9, 0x9e, 0xc5, 0x8c, 0xe9,
|
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{
|
rev = [chainhash.HashSize]byte{
|
||||||
0x51, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
|
0x51, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
|
||||||
0x48, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
|
0x48, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
|
||||||
@ -77,10 +65,6 @@ var (
|
|||||||
},
|
},
|
||||||
LockTime: 5,
|
LockTime: 5,
|
||||||
}
|
}
|
||||||
testOutpoint = &wire.OutPoint{
|
|
||||||
Hash: key,
|
|
||||||
Index: 0,
|
|
||||||
}
|
|
||||||
privKey, pubKey = btcec.PrivKeyFromBytes(btcec.S256(), key[:])
|
privKey, pubKey = btcec.PrivKeyFromBytes(btcec.S256(), key[:])
|
||||||
|
|
||||||
wireSig, _ = lnwire.NewSigFromSignature(testSig)
|
wireSig, _ = lnwire.NewSigFromSignature(testSig)
|
||||||
|
@ -15,9 +15,6 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/shachain"
|
"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
|
// writeOutpoint writes an outpoint to the passed writer using the minimal
|
||||||
// amount of bytes possible.
|
// amount of bytes possible.
|
||||||
func writeOutpoint(w io.Writer, o *wire.OutPoint) error {
|
func writeOutpoint(w io.Writer, o *wire.OutPoint) error {
|
||||||
|
@ -919,11 +919,6 @@ func uint16Key(i uint16) []byte {
|
|||||||
return key
|
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
|
// Compile-time constraint to ensure that ChannelPackager implements the public
|
||||||
// FwdPackager interface.
|
// FwdPackager interface.
|
||||||
var _ FwdPackager = (*ChannelPackager)(nil)
|
var _ FwdPackager = (*ChannelPackager)(nil)
|
||||||
|
@ -29,9 +29,7 @@ var (
|
|||||||
"[2001:db8:85a3:0:0:8a2e:370:7334]:80")
|
"[2001:db8:85a3:0:0:8a2e:370:7334]:80")
|
||||||
testAddrs = []net.Addr{testAddr, anotherAddr}
|
testAddrs = []net.Addr{testAddr, anotherAddr}
|
||||||
|
|
||||||
randSource = prand.NewSource(time.Now().Unix())
|
testSig = &btcec.Signature{
|
||||||
randInts = prand.New(randSource)
|
|
||||||
testSig = &btcec.Signature{
|
|
||||||
R: new(big.Int),
|
R: new(big.Int),
|
||||||
S: new(big.Int),
|
S: new(big.Int),
|
||||||
}
|
}
|
||||||
|
@ -101,14 +101,6 @@ func makeFakeInfo() (*PaymentCreationInfo, *PaymentAttemptInfo) {
|
|||||||
return c, a
|
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)
|
// randomBytes creates random []byte with length in range [minLen, maxLen)
|
||||||
func randomBytes(minLen, maxLen int) ([]byte, error) {
|
func randomBytes(minLen, maxLen int) ([]byte, error) {
|
||||||
randBuf := make([]byte, minLen+rand.Intn(maxLen-minLen))
|
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
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
@ -2818,37 +2818,6 @@ func describeGraph(ctx *cli.Context) error {
|
|||||||
return nil
|
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{
|
var listPaymentsCommand = cli.Command{
|
||||||
Name: "listpayments",
|
Name: "listpayments",
|
||||||
Category: "Payments",
|
Category: "Payments",
|
||||||
|
@ -23,7 +23,6 @@ type mockArbitratorLog struct {
|
|||||||
failCommit bool
|
failCommit bool
|
||||||
failCommitState ArbitratorState
|
failCommitState ArbitratorState
|
||||||
resolutions *ContractResolutions
|
resolutions *ContractResolutions
|
||||||
chainActions ChainActionMap
|
|
||||||
resolvers map[ContractResolver]struct{}
|
resolvers map[ContractResolver]struct{}
|
||||||
|
|
||||||
commitSet *CommitSet
|
commitSet *CommitSet
|
||||||
|
@ -43,10 +43,6 @@ var (
|
|||||||
_, _ = testSig.R.SetString("63724406601629180062774974542967536251589935445068131219452686511677818569431", 10)
|
_, _ = testSig.R.SetString("63724406601629180062774974542967536251589935445068131219452686511677818569431", 10)
|
||||||
_, _ = testSig.S.SetString("18801056069249825825291287104931333862866033135609736119018462340006816851118", 10)
|
_, _ = testSig.S.SetString("18801056069249825825291287104931333862866033135609736119018462340006816851118", 10)
|
||||||
|
|
||||||
inputStr = "147caa76786596590baa4e98f5d9f48b86c7765e489f7a6ff3360fe5c674360b"
|
|
||||||
sha, _ = chainhash.NewHashFromStr(inputStr)
|
|
||||||
outpoint = wire.NewOutPoint(sha, 0)
|
|
||||||
|
|
||||||
bitcoinKeyPriv1, _ = btcec.NewPrivateKey(btcec.S256())
|
bitcoinKeyPriv1, _ = btcec.NewPrivateKey(btcec.S256())
|
||||||
bitcoinKeyPub1 = bitcoinKeyPriv1.PubKey()
|
bitcoinKeyPub1 = bitcoinKeyPriv1.PubKey()
|
||||||
|
|
||||||
@ -59,10 +55,9 @@ var (
|
|||||||
nodeKeyPriv2, _ = btcec.NewPrivateKey(btcec.S256())
|
nodeKeyPriv2, _ = btcec.NewPrivateKey(btcec.S256())
|
||||||
nodeKeyPub2 = nodeKeyPriv2.PubKey()
|
nodeKeyPub2 = nodeKeyPriv2.PubKey()
|
||||||
|
|
||||||
trickleDelay = time.Millisecond * 100
|
trickleDelay = time.Millisecond * 100
|
||||||
retransmitDelay = time.Hour * 1
|
retransmitDelay = time.Hour * 1
|
||||||
proofMatureDelta uint32
|
proofMatureDelta uint32
|
||||||
maxBtcFundingAmount = btcutil.Amount(1<<62) - 1
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// makeTestDB creates a new instance of the ChannelDB for testing purposes. A
|
// makeTestDB creates a new instance of the ChannelDB for testing purposes. A
|
||||||
|
@ -116,10 +116,6 @@ type SyncManager struct {
|
|||||||
|
|
||||||
cfg SyncManagerCfg
|
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
|
// newSyncers is a channel we'll use to process requests to create
|
||||||
// GossipSyncers for newly connected peers.
|
// GossipSyncers for newly connected peers.
|
||||||
newSyncers chan *newSyncer
|
newSyncers chan *newSyncer
|
||||||
|
@ -187,10 +187,6 @@ type gossipSyncerCfg struct {
|
|||||||
// in compressed format.
|
// in compressed format.
|
||||||
peerPub [33]byte
|
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
|
// channelSeries is the primary interface that we'll use to generate
|
||||||
// our queries and respond to the queries of the remote peer.
|
// our queries and respond to the queries of the remote peer.
|
||||||
channelSeries ChannelGraphTimeSeries
|
channelSeries ChannelGraphTimeSeries
|
||||||
|
@ -17,7 +17,6 @@ import (
|
|||||||
const (
|
const (
|
||||||
defaultEncoding = lnwire.EncodingSortedPlain
|
defaultEncoding = lnwire.EncodingSortedPlain
|
||||||
latestKnownHeight = 1337
|
latestKnownHeight = 1337
|
||||||
startHeight = latestKnownHeight - chanRangeQueryBuffer
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -109,16 +109,6 @@ func CreateChanAnnouncement(chanProof *channeldb.ChannelAuthProof,
|
|||||||
return chanAnn, edge1Ann, edge2Ann, nil
|
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
|
// SignAnnouncement is a helper function which is used to sign any outgoing
|
||||||
// channel node node announcement messages.
|
// channel node node announcement messages.
|
||||||
func SignAnnouncement(signer lnwallet.MessageSigner, pubKey *btcec.PublicKey,
|
func SignAnnouncement(signer lnwallet.MessageSigner, pubKey *btcec.PublicKey,
|
||||||
|
@ -123,15 +123,6 @@ func (r *reservationWithCtx) isLocked() bool {
|
|||||||
return r.lastUpdated.IsZero()
|
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.
|
// updateTimestamp updates the reservation's timestamp with the current time.
|
||||||
func (r *reservationWithCtx) updateTimestamp() {
|
func (r *reservationWithCtx) updateTimestamp() {
|
||||||
r.updateMtx.Lock()
|
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
|
// chanAnnouncement encapsulates the two authenticated announcements that we
|
||||||
// send out to the network after a new channel has been created locally.
|
// send out to the network after a new channel has been created locally.
|
||||||
type chanAnnouncement struct {
|
type chanAnnouncement struct {
|
||||||
|
@ -49,8 +49,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
privPass = []byte("dummy-pass")
|
|
||||||
|
|
||||||
// Use hard-coded keys for Alice and Bob, the two FundingManagers that
|
// Use hard-coded keys for Alice and Bob, the two FundingManagers that
|
||||||
// we will test the interaction between.
|
// we will test the interaction between.
|
||||||
alicePrivKeyBytes = [32]byte{
|
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
|
// assertHasCircuitForHash tests that the provided circuit appears in the list
|
||||||
// of circuits for the given hash.
|
// of circuits for the given hash.
|
||||||
func assertHasCircuitForHash(t *testing.T, cm htlcswitch.CircuitMap, hash [32]byte,
|
func assertHasCircuitForHash(t *testing.T, cm htlcswitch.CircuitMap, hash [32]byte,
|
||||||
@ -619,17 +607,6 @@ func equalIgnoreLFD(c, c2 *htlcswitch.PaymentCircuit) bool {
|
|||||||
return isEqual
|
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
|
// 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
|
// the circuit map. If an empty string is provided as a path, a temp directory
|
||||||
// will be created.
|
// will be created.
|
||||||
|
@ -321,10 +321,6 @@ type channelLink struct {
|
|||||||
// been processed because of the commitment transaction overflow.
|
// been processed because of the commitment transaction overflow.
|
||||||
overflowQueue *packetQueue
|
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
|
// mailBox is the main interface between the outside world and the
|
||||||
// link. All incoming messages will be sent over this mailBox. Messages
|
// link. All incoming messages will be sent over this mailBox. Messages
|
||||||
// include new updates from our connected peer, and new packets to be
|
// include new updates from our connected peer, and new packets to be
|
||||||
|
@ -1690,7 +1690,6 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) (
|
|||||||
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
||||||
}
|
}
|
||||||
|
|
||||||
const startingHeight = 100
|
|
||||||
aliceLink := NewChannelLink(aliceCfg, aliceLc.channel)
|
aliceLink := NewChannelLink(aliceCfg, aliceLc.channel)
|
||||||
start := func() error {
|
start := func() error {
|
||||||
return aliceSwitch.AddLink(aliceLink)
|
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
|
// 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
|
// switch that operates it. It supports the ability to restart either the link
|
||||||
// or both the link and the switch.
|
// or both the link and the switch.
|
||||||
@ -4256,7 +4251,6 @@ func (h *persistentLinkHarness) restartLink(
|
|||||||
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
|
||||||
}
|
}
|
||||||
|
|
||||||
const startingHeight = 100
|
|
||||||
aliceLink := NewChannelLink(aliceCfg, aliceChannel)
|
aliceLink := NewChannelLink(aliceCfg, aliceChannel)
|
||||||
if err := aliceSwitch.AddLink(aliceLink); err != nil {
|
if err := aliceSwitch.AddLink(aliceLink); err != nil {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
@ -5394,7 +5388,6 @@ func TestChannelLinkFail(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const chanAmt = btcutil.SatoshiPerBitcoin * 5
|
const chanAmt = btcutil.SatoshiPerBitcoin * 5
|
||||||
const chanReserve = 0
|
|
||||||
|
|
||||||
// Execute each test case.
|
// Execute each test case.
|
||||||
for i, test := range testCases {
|
for i, test := range testCases {
|
||||||
|
@ -63,7 +63,6 @@ type memoryMailBox struct {
|
|||||||
stopped sync.Once
|
stopped sync.Once
|
||||||
|
|
||||||
wireMessages *list.List
|
wireMessages *list.List
|
||||||
wireHead *list.Element
|
|
||||||
wireMtx sync.Mutex
|
wireMtx sync.Mutex
|
||||||
wireCond *sync.Cond
|
wireCond *sync.Cond
|
||||||
|
|
||||||
|
@ -128,8 +128,6 @@ type mockServer struct {
|
|||||||
name string
|
name string
|
||||||
messages chan lnwire.Message
|
messages chan lnwire.Message
|
||||||
|
|
||||||
errChan chan error
|
|
||||||
|
|
||||||
id [33]byte
|
id [33]byte
|
||||||
htlcSwitch *Switch
|
htlcSwitch *Switch
|
||||||
|
|
||||||
@ -625,8 +623,6 @@ type mockChannelLink struct {
|
|||||||
|
|
||||||
peer lnpeer.Peer
|
peer lnpeer.Peer
|
||||||
|
|
||||||
startMailBox bool
|
|
||||||
|
|
||||||
mailBox MailBox
|
mailBox MailBox
|
||||||
|
|
||||||
packets chan *htlcPacket
|
packets chan *htlcPacket
|
||||||
|
@ -21,14 +21,6 @@ type htlcPacket struct {
|
|||||||
// on the incoming channel.
|
// on the incoming channel.
|
||||||
incomingHTLCID uint64
|
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
|
// outgoingHTLCID is the ID of the HTLC that we offered to the peer on the
|
||||||
// outgoing channel.
|
// outgoing channel.
|
||||||
outgoingHTLCID uint64
|
outgoingHTLCID uint64
|
||||||
|
@ -2,7 +2,6 @@ package htlcswitch
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha256"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
@ -66,10 +65,6 @@ var (
|
|||||||
// ErrUnreadableFailureMessage is returned when the failure message
|
// ErrUnreadableFailureMessage is returned when the failure message
|
||||||
// cannot be decrypted.
|
// cannot be decrypted.
|
||||||
ErrUnreadableFailureMessage = errors.New("unreadable failure message")
|
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
|
// plexPacket encapsulates switch packet and adds error channel to receive
|
||||||
@ -258,10 +253,6 @@ type Switch struct {
|
|||||||
// messages will be sent over.
|
// messages will be sent over.
|
||||||
resolutionMsgs chan *resolutionMsg
|
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
|
// pendingFwdingEvents is the set of forwarding events which have been
|
||||||
// collected during the current interval, but hasn't yet been written
|
// collected during the current interval, but hasn't yet been written
|
||||||
// to the forwarding log.
|
// to the forwarding log.
|
||||||
@ -2225,18 +2216,6 @@ func (s *Switch) deleteCircuits(inKeys ...CircuitKey) error {
|
|||||||
return s.circuits.DeleteCircuits(inKeys...)
|
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
|
// FlushForwardingEvents flushes out the set of pending forwarding events to
|
||||||
// the persistent log. This will be used by the switch to periodically flush
|
// 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
|
// out the set of forwarding events to disk. External callers can also use this
|
||||||
|
@ -41,15 +41,7 @@ var (
|
|||||||
bobPrivKey = []byte("bob priv key")
|
bobPrivKey = []byte("bob priv key")
|
||||||
carolPrivKey = []byte("carol priv key")
|
carolPrivKey = []byte("carol priv key")
|
||||||
|
|
||||||
testPrivKey = []byte{
|
testSig = &btcec.Signature{
|
||||||
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{
|
|
||||||
R: new(big.Int),
|
R: new(big.Int),
|
||||||
S: new(big.Int),
|
S: new(big.Int),
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,6 @@ var (
|
|||||||
|
|
||||||
// errNoUpdate is returned when no invoice updated is required.
|
// errNoUpdate is returned when no invoice updated is required.
|
||||||
errNoUpdate = errors.New("no update needed")
|
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
|
// HodlEvent describes how an htlc should be resolved. If HodlEvent.Preimage is
|
||||||
|
@ -23,8 +23,6 @@ var (
|
|||||||
|
|
||||||
testHtlcExpiry = uint32(5)
|
testHtlcExpiry = uint32(5)
|
||||||
|
|
||||||
testInvoiceCltvDelta = uint32(4)
|
|
||||||
|
|
||||||
testFinalCltvRejectDelta = int32(4)
|
testFinalCltvRejectDelta = int32(4)
|
||||||
|
|
||||||
testCurrentHeight = int32(1)
|
testCurrentHeight = int32(1)
|
||||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
|||||||
|
|
||||||
// logClosure is used to provide a closure over expensive logging operations so
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
|||||||
|
|
||||||
// logClosure is used to provide a closure over expensive logging operations so
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,6 @@ var (
|
|||||||
// RPC server allows external callers to access the status of the invoices
|
// RPC server allows external callers to access the status of the invoices
|
||||||
// currently active within lnd, as well as configuring it at runtime.
|
// currently active within lnd, as well as configuring it at runtime.
|
||||||
type Server struct {
|
type Server struct {
|
||||||
started int32 // To be used atomically.
|
|
||||||
shutdown int32 // To be used atomically.
|
|
||||||
|
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
|
|
||||||
cfg *Config
|
cfg *Config
|
||||||
|
@ -33,7 +33,7 @@ func UseLogger(logger btclog.Logger) {
|
|||||||
|
|
||||||
// logClosure is used to provide a closure over expensive logging operations so
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
|||||||
|
|
||||||
// logClosure is used to provide a closure over expensive logging operations so
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
|||||||
|
|
||||||
// logClosure is used to provide a closure over expensive logging operations so
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func UseLogger(logger btclog.Logger) {
|
|||||||
|
|
||||||
// logClosure is used to provide a closure over expensive logging operations so
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func UseLogger(logger btclog.Logger) {
|
|||||||
|
|
||||||
// logClosure is used to provide a closure over expensive logging operations so
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
|
||||||
|
|
||||||
"github.com/btcsuite/btcwallet/chain"
|
"github.com/btcsuite/btcwallet/chain"
|
||||||
"github.com/btcsuite/btcwallet/wallet"
|
"github.com/btcsuite/btcwallet/wallet"
|
||||||
@ -19,25 +18,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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
|
// defaultPubPassphrase is the default public wallet passphrase which is
|
||||||
// used when the user indicates they do not want additional protection
|
// used when the user indicates they do not want additional protection
|
||||||
// provided by having all public data in the wallet encrypted by a
|
// provided by having all public data in the wallet encrypted by a
|
||||||
// passphrase only known to them.
|
// passphrase only known to them.
|
||||||
defaultPubPassphrase = []byte("public")
|
defaultPubPassphrase = []byte("public")
|
||||||
|
|
||||||
walletDbName = "lnwallet.db"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is a struct which houses configuration parameters which modify the
|
// Config is a struct which houses configuration parameters which modify the
|
||||||
|
@ -109,7 +109,7 @@ type channelState uint8
|
|||||||
const (
|
const (
|
||||||
// channelPending indicates this channel is still going through the
|
// channelPending indicates this channel is still going through the
|
||||||
// funding workflow, and isn't yet open.
|
// funding workflow, and isn't yet open.
|
||||||
channelPending channelState = iota
|
channelPending channelState = iota // nolint: unused
|
||||||
|
|
||||||
// channelOpen represents an open, active channel capable of
|
// channelOpen represents an open, active channel capable of
|
||||||
// sending/receiving HTLCs.
|
// sending/receiving HTLCs.
|
||||||
@ -130,7 +130,7 @@ const (
|
|||||||
|
|
||||||
// channelPendingPayment indicates that there a currently outstanding
|
// channelPendingPayment indicates that there a currently outstanding
|
||||||
// HTLCs within the channel.
|
// HTLCs within the channel.
|
||||||
channelPendingPayment
|
channelPendingPayment // nolint:unused
|
||||||
)
|
)
|
||||||
|
|
||||||
// PaymentHash represents the sha256 of a random value. This hash is used to
|
// 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,
|
// Once a commitment transaction is revoked, the tail is incremented,
|
||||||
// freeing up the revocation window for new commitments.
|
// freeing up the revocation window for new commitments.
|
||||||
commitments *list.List
|
commitments *list.List
|
||||||
|
|
||||||
// startingHeight is the starting height of this commitment chain on a
|
|
||||||
// session basis.
|
|
||||||
startingHeight uint64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// newCommitmentChain creates a new commitment chain.
|
// newCommitmentChain creates a new commitment chain.
|
||||||
@ -1296,8 +1292,6 @@ type LightningChannel struct {
|
|||||||
// the commitment transaction that spends the multi-sig output.
|
// the commitment transaction that spends the multi-sig output.
|
||||||
signDesc *input.SignDescriptor
|
signDesc *input.SignDescriptor
|
||||||
|
|
||||||
channelEvents chainntnfs.ChainNotifier
|
|
||||||
|
|
||||||
status channelState
|
status channelState
|
||||||
|
|
||||||
// ChanPoint is the funding outpoint of this channel.
|
// ChanPoint is the funding outpoint of this channel.
|
||||||
|
@ -1311,7 +1311,6 @@ func TestStateUpdatePersistence(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
const numHtlcs = 4
|
|
||||||
htlcAmt := lnwire.NewMSatFromSatoshis(5000)
|
htlcAmt := lnwire.NewMSatFromSatoshis(5000)
|
||||||
|
|
||||||
var fakeOnionBlob [lnwire.OnionPacketSize]byte
|
var fakeOnionBlob [lnwire.OnionPacketSize]byte
|
||||||
|
@ -43,16 +43,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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{
|
bobsPrivKey = []byte{
|
||||||
0x81, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
|
0x81, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
|
||||||
0x63, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
|
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) {
|
func assertReservationDeleted(res *lnwallet.ChannelReservation, t *testing.T) {
|
||||||
if err := res.Cancel(); err == nil {
|
if err := res.Cancel(); err == nil {
|
||||||
t.Fatalf("reservation wasn't deleted from wallet")
|
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)
|
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,
|
func loadTestCredits(miner *rpctest.Harness, w *lnwallet.LightningWallet,
|
||||||
numOutputs int, btcPerOutput float64) error {
|
numOutputs int, btcPerOutput float64) error {
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec"
|
"github.com/btcsuite/btcd/btcec"
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
@ -17,14 +16,11 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/lightningnetwork/lnd/shachain"
|
"github.com/lightningnetwork/lnd/shachain"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
privPass = []byte("private-test")
|
|
||||||
|
|
||||||
// For simplicity a single priv key controls all of our test outputs.
|
// For simplicity a single priv key controls all of our test outputs.
|
||||||
testWalletPrivKey = []byte{
|
testWalletPrivKey = []byte{
|
||||||
0x2b, 0xd8, 0x06, 0xc9, 0x7f, 0x0e, 0x00, 0xaf,
|
0x2b, 0xd8, 0x06, 0xc9, 0x7f, 0x0e, 0x00, 0xaf,
|
||||||
@ -49,10 +45,6 @@ var (
|
|||||||
0x6a, 0x49, 0x18, 0x83, 0x31, 0x98, 0x47, 0x53,
|
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.
|
// A serializable txn for testing funding txn.
|
||||||
testTx = &wire.MsgTx{
|
testTx = &wire.MsgTx{
|
||||||
Version: 1,
|
Version: 1,
|
||||||
@ -382,43 +374,6 @@ func initRevocationWindows(chanA, chanB *LightningChannel) error {
|
|||||||
return nil
|
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.
|
// pubkeyFromHex parses a Bitcoin public key from a hex encoded string.
|
||||||
func pubkeyFromHex(keyHex string) (*btcec.PublicKey, error) {
|
func pubkeyFromHex(keyHex string) (*btcec.PublicKey, error) {
|
||||||
bytes, err := hex.DecodeString(keyHex)
|
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.
|
// blockFromHex parses a full Bitcoin block from a hex encoded string.
|
||||||
func blockFromHex(blockHex string) (*btcutil.Block, error) {
|
func blockFromHex(blockHex string) (*btcutil.Block, error) {
|
||||||
bytes, err := hex.DecodeString(blockHex)
|
bytes, err := hex.DecodeString(blockHex)
|
||||||
|
@ -222,11 +222,10 @@ func newTestContext() (tc *testContext, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
htlcData := []struct {
|
htlcData := []struct {
|
||||||
incoming bool
|
incoming bool
|
||||||
amount lnwire.MilliSatoshi
|
amount lnwire.MilliSatoshi
|
||||||
expiry uint32
|
expiry uint32
|
||||||
preimage string
|
preimage string
|
||||||
paymentHash PaymentHash
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
incoming: true,
|
incoming: true,
|
||||||
|
@ -253,10 +253,6 @@ type LightningWallet struct {
|
|||||||
// keys, revocation keys, etc.
|
// keys, revocation keys, etc.
|
||||||
keychain.SecretKeyRing
|
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
|
// This mutex MUST be held when performing coin selection in order to
|
||||||
// avoid inadvertently creating multiple funding transaction which
|
// avoid inadvertently creating multiple funding transaction which
|
||||||
// double spend inputs across each other.
|
// 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
|
// pertaining to the exact location in the main chain in-which the transaction
|
||||||
// was confirmed.
|
// was confirmed.
|
||||||
type openChanDetails struct {
|
type openChanDetails struct {
|
||||||
channel *LightningChannel
|
|
||||||
blockHeight uint32
|
|
||||||
txIndex uint32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleFundingCounterPartySigs is the final step in the channel reservation
|
// handleFundingCounterPartySigs is the final step in the channel reservation
|
||||||
|
@ -23,13 +23,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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")
|
shaHash1Bytes, _ = hex.DecodeString("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
|
||||||
shaHash1, _ = chainhash.NewHash(shaHash1Bytes)
|
shaHash1, _ = chainhash.NewHash(shaHash1Bytes)
|
||||||
outpoint1 = wire.NewOutPoint(shaHash1, 0)
|
outpoint1 = wire.NewOutPoint(shaHash1, 0)
|
||||||
|
@ -10,11 +10,6 @@ import (
|
|||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
startPort uint16 = 1024
|
|
||||||
endPort uint16 = 49151
|
|
||||||
)
|
|
||||||
|
|
||||||
// ErrUnknownAddrType is an error returned if we encounter an unknown address type
|
// ErrUnknownAddrType is an error returned if we encounter an unknown address type
|
||||||
// when parsing addresses.
|
// when parsing addresses.
|
||||||
type ErrUnknownAddrType struct {
|
type ErrUnknownAddrType struct {
|
||||||
|
32
mock.go
32
mock.go
@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -228,7 +227,6 @@ func (*mockChainIO) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error)
|
|||||||
// interaction with the bitcoin network.
|
// interaction with the bitcoin network.
|
||||||
type mockWalletController struct {
|
type mockWalletController struct {
|
||||||
rootKey *btcec.PrivateKey
|
rootKey *btcec.PrivateKey
|
||||||
prevAddres btcutil.Address
|
|
||||||
publishedTransactions chan *wire.MsgTx
|
publishedTransactions chan *wire.MsgTx
|
||||||
index uint32
|
index uint32
|
||||||
utxos []*lnwallet.Utxo
|
utxos []*lnwallet.Utxo
|
||||||
@ -355,33 +353,3 @@ func (m *mockSecretKeyRing) ScalarMult(keyDesc keychain.KeyDescriptor,
|
|||||||
pubKey *btcec.PublicKey) ([]byte, error) {
|
pubKey *btcec.PublicKey) ([]byte, error) {
|
||||||
return nil, nil
|
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
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,6 @@ func createEdgePolicies(t *testing.T, channel *channeldb.OpenChannel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
type mockGraph struct {
|
type mockGraph struct {
|
||||||
pubKey *btcec.PublicKey
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
channels []*channeldb.OpenChannel
|
channels []*channeldb.OpenChannel
|
||||||
chanInfos map[wire.OutPoint]*channeldb.ChannelEdgeInfo
|
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
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
11
peer.go
11
peer.go
@ -30,10 +30,6 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/ticker"
|
"github.com/lightningnetwork/lnd/ticker"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
numNodes int32
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// pingInterval is the interval at which ping messages are sent.
|
// pingInterval is the interval at which ping messages are sent.
|
||||||
pingInterval = 1 * time.Minute
|
pingInterval = 1 * time.Minute
|
||||||
@ -82,12 +78,6 @@ type closeMsg struct {
|
|||||||
msg lnwire.Message
|
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.
|
// pendingUpdate describes the pending state of a closing channel.
|
||||||
type pendingUpdate struct {
|
type pendingUpdate struct {
|
||||||
Txid []byte
|
Txid []byte
|
||||||
@ -717,7 +707,6 @@ type msgStream struct {
|
|||||||
|
|
||||||
mtx sync.Mutex
|
mtx sync.Mutex
|
||||||
|
|
||||||
bufSize uint32
|
|
||||||
producerSema chan struct{}
|
producerSema chan struct{}
|
||||||
|
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
@ -437,7 +437,6 @@ func (b *BtcdFilteredChainView) chainFilterer() {
|
|||||||
type filterUpdate struct {
|
type filterUpdate struct {
|
||||||
newUtxos []wire.OutPoint
|
newUtxos []wire.OutPoint
|
||||||
updateHeight uint32
|
updateHeight uint32
|
||||||
done chan struct{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateFilter updates the UTXO filter which is to be consulted when creating
|
// UpdateFilter updates the UTXO filter which is to be consulted when creating
|
||||||
|
@ -3,7 +3,6 @@ package routing
|
|||||||
import (
|
import (
|
||||||
"container/heap"
|
"container/heap"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/lightningnetwork/lnd/routing/route"
|
"github.com/lightningnetwork/lnd/routing/route"
|
||||||
)
|
)
|
||||||
@ -120,62 +119,3 @@ func (d *distanceHeap) PushOrFix(dist nodeWithDist) {
|
|||||||
// Call heap.Fix to reorder the heap.
|
// Call heap.Fix to reorder the heap.
|
||||||
heap.Fix(d, index)
|
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
|
utxos map[wire.OutPoint]wire.TxOut
|
||||||
|
|
||||||
bestHeight int32
|
bestHeight int32
|
||||||
bestHash *chainhash.Hash
|
|
||||||
|
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
}
|
}
|
||||||
|
@ -75,22 +75,6 @@ func computeFee(amt lnwire.MilliSatoshi,
|
|||||||
return edge.FeeBaseMSat + (amt*edge.FeeProportionalMillionths)/1000000
|
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
|
// newRoute returns a fully valid route between the source and target that's
|
||||||
// capable of supporting a payment of `amtToSend` after fees are fully
|
// 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
|
// computed. If the route is too long, or the selected path cannot support the
|
||||||
|
@ -324,21 +324,6 @@ type testChannelEnd struct {
|
|||||||
*testChannelPolicy
|
*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,
|
func symmetricTestChannel(alias1 string, alias2 string, capacity btcutil.Amount,
|
||||||
policy *testChannelPolicy, chanID ...uint64) *testChannel {
|
policy *testChannelPolicy, chanID ...uint64) *testChannel {
|
||||||
|
|
||||||
@ -1675,13 +1660,6 @@ func TestPathFindSpecExample(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
const (
|
|
||||||
aliceFinalCLTV = 10
|
|
||||||
bobFinalCLTV = 20
|
|
||||||
carolFinalCLTV = 30
|
|
||||||
daveFinalCLTV = 40
|
|
||||||
)
|
|
||||||
|
|
||||||
// We'll first exercise the scenario of a direct payment from Bob to
|
// 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
|
// Carol, so we set "B" as the source node so path finding starts from
|
||||||
// Bob.
|
// Bob.
|
||||||
|
@ -137,9 +137,3 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
|
|||||||
|
|
||||||
return route, err
|
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
|
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.
|
// EdgeLocator is a struct used to identify a specific edge.
|
||||||
type EdgeLocator struct {
|
type EdgeLocator struct {
|
||||||
// ChannelID is the channel of this edge.
|
// ChannelID is the channel of this edge.
|
||||||
@ -325,31 +306,6 @@ type EdgeLocator struct {
|
|||||||
Direction uint8
|
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.
|
// String returns a human readable version of the edgeLocator values.
|
||||||
func (e *EdgeLocator) String() string {
|
func (e *EdgeLocator) String() string {
|
||||||
return fmt.Sprintf("%v:%v", e.ChannelID, e.Direction)
|
return fmt.Sprintf("%v:%v", e.ChannelID, e.Direction)
|
||||||
|
@ -67,14 +67,6 @@ func (c *testCtx) RestartRouter() error {
|
|||||||
return nil
|
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) (
|
func createTestCtxFromGraphInstance(startingHeight uint32, graphInstance *testGraphInstance) (
|
||||||
*testCtx, func(), error) {
|
*testCtx, func(), error) {
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ import (
|
|||||||
"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/btcsuite/btcwallet/waddrmgr"
|
|
||||||
"github.com/btcsuite/btcwallet/wallet/txauthor"
|
"github.com/btcsuite/btcwallet/wallet/txauthor"
|
||||||
"github.com/coreos/bbolt"
|
"github.com/coreos/bbolt"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
@ -77,8 +76,6 @@ var (
|
|||||||
// It is set to the value under the Bitcoin chain as default.
|
// It is set to the value under the Bitcoin chain as default.
|
||||||
MaxPaymentMSat = maxBtcPaymentMSat
|
MaxPaymentMSat = maxBtcPaymentMSat
|
||||||
|
|
||||||
defaultAccount uint32 = waddrmgr.DefaultAccountNum
|
|
||||||
|
|
||||||
// readPermissions is a slice of all entities that allow read
|
// readPermissions is a slice of all entities that allow read
|
||||||
// permissions for authorization purposes, all lowercase.
|
// permissions for authorization purposes, all lowercase.
|
||||||
readPermissions = []bakery.Op{
|
readPermissions = []bakery.Op{
|
||||||
@ -396,8 +393,6 @@ type rpcServer struct {
|
|||||||
|
|
||||||
server *server
|
server *server
|
||||||
|
|
||||||
wg sync.WaitGroup
|
|
||||||
|
|
||||||
// subServers are a set of sub-RPC servers that use the same gRPC and
|
// 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
|
// listening sockets as the main RPC server, but which maintain their
|
||||||
// own independent service. This allows us to expose a set of
|
// own independent service. This allows us to expose a set of
|
||||||
|
@ -6,25 +6,6 @@ import (
|
|||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"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.
|
// getBit return bit on index at position.
|
||||||
func getBit(index index, position uint8) uint8 {
|
func getBit(index index, position uint8) uint8 {
|
||||||
return uint8((uint64(index) >> position) & 1)
|
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
|
// assertTxSweepsInputs ensures that the transaction returned within the value
|
||||||
// received from resultChan spends the given inputs.
|
// received from resultChan spends the given inputs.
|
||||||
func assertTxSweepsInputs(t *testing.T, sweepTx *wire.MsgTx,
|
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)
|
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 {
|
type mockSweeper struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
|
|
||||||
|
@ -18,10 +18,6 @@ import (
|
|||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
walletDbName = "wallet.db"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
testPassword = []byte("test-password")
|
testPassword = []byte("test-password")
|
||||||
testSeed = []byte("test-seed-123456789")
|
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
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,6 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/watchtower/wtwire"
|
"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.
|
// reserveStatus is an enum that signals how full a particular session is.
|
||||||
type reserveStatus uint8
|
type reserveStatus uint8
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ func UseLogger(logger btclog.Logger) {
|
|||||||
|
|
||||||
// logClosure is used to provide a closure over expensive logging operations so
|
// 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.
|
// 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.
|
// String invokes the underlying function and returns the result.
|
||||||
func (c logClosure) String() string {
|
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
|
// 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
|
// which itself provides a Stringer interface so that it can be used with the
|
||||||
// logging system.
|
// logging system.
|
||||||
func newLogClosure(c func() string) logClosure {
|
func newLogClosure(c func() string) logClosure { // nolint:unused
|
||||||
return logClosure(c)
|
return logClosure(c)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user