multi: remove dead code
This commit is contained in:
71 files changed
+35
-766
No files matched your search
@@ -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
|
||||
|
||||
+2
-8
@@ -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
|
||||
|
||||
Reference in new issue
Block a user