Skip to content

Commit

Permalink
multi: update lnd dependency to v0.14.1-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
guggero committed Dec 13, 2021
1 parent 050253e commit a239f94
Show file tree
Hide file tree
Showing 20 changed files with 734 additions and 219 deletions.
2 changes: 1 addition & 1 deletion cmd/chantools/deletepayments.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If only the failed payments should be deleted (and not the successful ones), the
CAUTION: Running this command will make it impossible to use the channel DB
with an older version of lnd. Downgrading is not possible and you'll need to
run lnd v0.13.1-beta or later after using this command!'`,
run lnd v0.14.1-beta or later after using this command!'`,
Example: `chantools deletepayments --failedonly \
--channeldb ~/.lnd/data/graph/mainnet/channel.db`,
RunE: cc.Execute,
Expand Down
2 changes: 1 addition & 1 deletion cmd/chantools/dropchannelgraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ without removing any other data.
CAUTION: Running this command will make it impossible to use the channel DB
with an older version of lnd. Downgrading is not possible and you'll need to
run lnd v0.13.1-beta or later after using this command!'`,
run lnd v0.14.1-beta or later after using this command!'`,
Example: `chantools dropchannelgraph \
--channeldb ~/.lnd/data/graph/mainnet/channel.db
Expand Down
8 changes: 4 additions & 4 deletions cmd/chantools/dumpchannels.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ func (c *dumpChannelsCommand) Execute(_ *cobra.Command, _ []string) error {
defer func() { _ = db.Close() }()

if c.Closed {
return dumpClosedChannelInfo(db)
return dumpClosedChannelInfo(db.ChannelStateDB())
}
return dumpOpenChannelInfo(db)
return dumpOpenChannelInfo(db.ChannelStateDB())
}

func dumpOpenChannelInfo(chanDb *channeldb.DB) error {
func dumpOpenChannelInfo(chanDb *channeldb.ChannelStateDB) error {
channels, err := chanDb.FetchAllChannels()
if err != nil {
return err
Expand All @@ -77,7 +77,7 @@ func dumpOpenChannelInfo(chanDb *channeldb.DB) error {
return nil
}

func dumpClosedChannelInfo(chanDb *channeldb.DB) error {
func dumpClosedChannelInfo(chanDb *channeldb.ChannelStateDB) error {
channels, err := chanDb.FetchClosedChannels(false)
if err != nil {
return err
Expand Down
6 changes: 4 additions & 2 deletions cmd/chantools/forceclose.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ func (c *forceCloseCommand) Execute(_ *cobra.Command, _ []string) error {
if err != nil {
return err
}
return forceCloseChannels(c.APIURL, extendedKey, entries, db, c.Publish)
return forceCloseChannels(
c.APIURL, extendedKey, entries, db.ChannelStateDB(), c.Publish,
)
}

func forceCloseChannels(apiURL string, extendedKey *hdkeychain.ExtendedKey,
entries []*dataformat.SummaryEntry, chanDb *channeldb.DB,
entries []*dataformat.SummaryEntry, chanDb *channeldb.ChannelStateDB,
publish bool) error {

channels, err := chanDb.FetchAllChannels()
Expand Down
2 changes: 1 addition & 1 deletion cmd/chantools/migratedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ needs to read the database content.
CAUTION: Running this command will make it impossible to use the channel DB
with an older version of lnd. Downgrading is not possible and you'll need to
run lnd v0.13.1-beta or later after using this command!'`,
run lnd v0.14.1-beta or later after using this command!'`,
Example: `chantools migratedb \
--channeldb ~/.lnd/data/graph/mainnet/channel.db`,
RunE: cc.Execute,
Expand Down
10 changes: 6 additions & 4 deletions cmd/chantools/removechannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ channel was never confirmed on chain!
CAUTION: Running this command will make it impossible to use the channel DB
with an older version of lnd. Downgrading is not possible and you'll need to
run lnd v0.13.1-beta or later after using this command!`,
run lnd v0.14.1-beta or later after using this command!`,
Example: `chantools removechannel \
--channeldb ~/.lnd/data/graph/mainnet/channel.db \
--channel 3149764effbe82718b280de425277e5e7b245a4573aa4a0203ac12cee1c37816:0`,
Expand Down Expand Up @@ -78,14 +78,16 @@ func (c *removeChannelCommand) Execute(_ *cobra.Command, _ []string) error {
return err
}

return removeChannel(db, &wire.OutPoint{
return removeChannel(db.ChannelStateDB(), &wire.OutPoint{
Hash: *hash,
Index: uint32(index),
})
}

func removeChannel(db *channeldb.DB, chanPoint *wire.OutPoint) error {
dbChan, err := db.FetchChannel(*chanPoint)
func removeChannel(db *channeldb.ChannelStateDB,
chanPoint *wire.OutPoint) error {

dbChan, err := db.FetchChannel(nil, *chanPoint)
if err != nil {
return err
}
Expand Down
6 changes: 4 additions & 2 deletions cmd/chantools/rescueclosed.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (c *rescueClosedCommand) Execute(_ *cobra.Command, _ []string) error {
return err
}

commitPoints, err := commitPointsFromDB(db)
commitPoints, err := commitPointsFromDB(db.ChannelStateDB())
if err != nil {
return fmt.Errorf("error reading commit points from "+
"db: %v", err)
Expand Down Expand Up @@ -176,7 +176,9 @@ func (c *rescueClosedCommand) Execute(_ *cobra.Command, _ []string) error {
}
}

func commitPointsFromDB(chanDb *channeldb.DB) ([]*btcec.PublicKey, error) {
func commitPointsFromDB(chanDb *channeldb.ChannelStateDB) ([]*btcec.PublicKey,
error) {

var result []*btcec.PublicKey

channels, err := chanDb.FetchAllChannels()
Expand Down
4 changes: 3 additions & 1 deletion cmd/chantools/rescuefunding.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ func (c *rescueFundingCommand) Execute(_ *cobra.Command, _ []string) error {
}

// First, make sure the channel can be found in the DB.
pendingChan, err := db.FetchChannel(*databaseOp)
pendingChan, err := db.ChannelStateDB().FetchChannel(
nil, *databaseOp,
)
if err != nil {
return fmt.Errorf("error loading pending channel %s "+
"from DB: %v", databaseOp, err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/chantools/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

const (
defaultAPIURL = "https://blockstream.info/api"
version = "0.9.6"
version = "0.10.0"
na = "n/a"

Commit = ""
Expand Down Expand Up @@ -211,7 +211,7 @@ func (f *inputFlags) parseInputType() ([]*dataformat.SummaryEntry, error) {
return nil, fmt.Errorf("error opening channel DB: %v",
err)
}
target = &dataformat.ChannelDBFile{DB: db}
target = &dataformat.ChannelDBFile{DB: db.ChannelStateDB()}
return target.AsSummaryEntries()

default:
Expand Down
48 changes: 25 additions & 23 deletions cmd/chantools/zombierecovery_makeoffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil/psbt"
"github.com/btcsuite/btcwallet/wallet/txrules"
"github.com/guggero/chantools/lnd"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -330,11 +330,31 @@ channelLoop:
return fmt.Errorf("error distributing fees, unhandled case")
}

// Our output.
pkScript, err := lnd.GetP2WPKHScript(ourPayoutAddr, chainParams)
if err != nil {
return fmt.Errorf("error parsing our payout address: %v", err)
}
ourTxOut := &wire.TxOut{
PkScript: pkScript,
Value: ourSum,
}

// Their output
pkScript, err = lnd.GetP2WPKHScript(theirPayoutAddr, chainParams)
if err != nil {
return fmt.Errorf("error parsing their payout address: %v", err)
}
theirTxOut := &wire.TxOut{
PkScript: pkScript,
Value: theirSum,
}

// Don't create dust.
if ourSum <= int64(lnwallet.DefaultDustLimit()) {
if txrules.IsDustOutput(ourTxOut, txrules.DefaultRelayFeePerKb) {
ourSum = 0
}
if theirSum <= int64(lnwallet.DefaultDustLimit()) {
if txrules.IsDustOutput(theirTxOut, txrules.DefaultRelayFeePerKb) {
theirSum = 0
}

Expand All @@ -346,28 +366,10 @@ channelLoop:
// And now create the PSBT.
tx := wire.NewMsgTx(2)
if ourSum > 0 {
pkScript, err := lnd.GetP2WPKHScript(ourPayoutAddr, chainParams)
if err != nil {
return fmt.Errorf("error parsing our payout address: "+
"%v", err)
}
tx.TxOut = append(tx.TxOut, &wire.TxOut{
PkScript: pkScript,
Value: ourSum,
})
tx.TxOut = append(tx.TxOut, ourTxOut)
}
if theirSum > 0 {
pkScript, err := lnd.GetP2WPKHScript(
theirPayoutAddr, chainParams,
)
if err != nil {
return fmt.Errorf("error parsing their payout "+
"address: %v", err)
}
tx.TxOut = append(tx.TxOut, &wire.TxOut{
PkScript: pkScript,
Value: theirSum,
})
tx.TxOut = append(tx.TxOut, theirTxOut)
}
for _, txIn := range inputs {
tx.TxIn = append(tx.TxIn, &wire.TxIn{
Expand Down
2 changes: 1 addition & 1 deletion dataformat/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (c *PendingChannelsChannel) AsSummaryEntry() *SummaryEntry {
}

type ChannelDBFile struct {
DB *channeldb.DB
DB *channeldb.ChannelStateDB
}

func (c *ChannelDBFile) AsSummaryEntries() ([]*SummaryEntry, error) {
Expand Down
2 changes: 1 addition & 1 deletion doc/chantools_deletepayments.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ If only the failed payments should be deleted (and not the successful ones), the

CAUTION: Running this command will make it impossible to use the channel DB
with an older version of lnd. Downgrading is not possible and you'll need to
run lnd v0.13.1-beta or later after using this command!'
run lnd v0.14.1-beta or later after using this command!'

```
chantools deletepayments [flags]
Expand Down
2 changes: 1 addition & 1 deletion doc/chantools_dropchannelgraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ without removing any other data.

CAUTION: Running this command will make it impossible to use the channel DB
with an older version of lnd. Downgrading is not possible and you'll need to
run lnd v0.13.1-beta or later after using this command!'
run lnd v0.14.1-beta or later after using this command!'

```
chantools dropchannelgraph [flags]
Expand Down
2 changes: 1 addition & 1 deletion doc/chantools_fakechanbackup.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ chantools fakechanbackup --from_channel_graph lncli_describegraph.json \
--channelpoint string funding transaction outpoint of the channel to rescue (<txid>:<txindex>) as it is displayed on 1ml.com
--from_channel_graph string the full LN channel graph in the JSON format that the 'lncli describegraph' returns
-h, --help help for fakechanbackup
--multi_file string the fake channel backup file to create (default "results/fake-2021-11-11-13-31-59.backup")
--multi_file string the fake channel backup file to create (default "results/fake-2021-12-13-10-34-21.backup")
--remote_node_addr string the remote node connection information in the format pubkey@host:port
--rootkey string BIP32 HD root key of the wallet to use for encrypting the backup; leave empty to prompt for lnd 24 word aezeed
--short_channel_id string the short channel ID in the format <blockheight>x<transactionindex>x<outputindex>
Expand Down
2 changes: 1 addition & 1 deletion doc/chantools_migratedb.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ needs to read the database content.

CAUTION: Running this command will make it impossible to use the channel DB
with an older version of lnd. Downgrading is not possible and you'll need to
run lnd v0.13.1-beta or later after using this command!'
run lnd v0.14.1-beta or later after using this command!'

```
chantools migratedb [flags]
Expand Down
2 changes: 1 addition & 1 deletion doc/chantools_removechannel.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ channel was never confirmed on chain!

CAUTION: Running this command will make it impossible to use the channel DB
with an older version of lnd. Downgrading is not possible and you'll need to
run lnd v0.13.1-beta or later after using this command!
run lnd v0.14.1-beta or later after using this command!

```
chantools removechannel [flags]
Expand Down
35 changes: 12 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,28 @@ module github.com/guggero/chantools
require (
git.schwanenlied.me/yawning/bsaes.git v0.0.0-20190320102049-26d1add596b6 // indirect
github.com/Yawning/aez v0.0.0-20180408160647-ec7426b44926 // indirect
github.com/btcsuite/btcd v0.21.0-beta.0.20210513141527-ee5896bad5be
github.com/btcsuite/btcd v0.22.0-beta.0.20211005184431-e3449998be39
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
github.com/btcsuite/btcutil v1.0.3-0.20210527170813-e2ba6805a890
github.com/btcsuite/btcutil/psbt v1.0.3-0.20210527170813-e2ba6805a890
github.com/btcsuite/btcwallet v0.12.1-0.20210519225359-6ab9b615576f
github.com/btcsuite/btcwallet/walletdb v1.3.5
github.com/btcsuite/btcwallet v0.13.0
github.com/btcsuite/btcwallet/wallet/txrules v1.1.0
github.com/btcsuite/btcwallet/walletdb v1.3.6-0.20210803004036-eebed51155ec
github.com/coreos/bbolt v1.3.3
github.com/davecgh/go-spew v1.1.1
github.com/frankban/quicktest v1.11.2 // indirect
github.com/gogo/protobuf v1.2.1
github.com/google/go-cmp v0.5.3 // indirect
github.com/lightningnetwork/lnd v0.13.1-beta
github.com/gogo/protobuf v1.3.2
github.com/lightningnetwork/lnd v0.14.1-beta
github.com/lightningnetwork/lnd/kvdb v1.2.1
github.com/ltcsuite/ltcd v0.0.0-20191228044241-92166e412499 // indirect
github.com/miekg/dns v1.1.26 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/cobra v1.1.1
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0
go.etcd.io/bbolt v1.3.5-0.20200615073812-232d8fc87f50
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
golang.org/x/text v0.3.4 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
go.etcd.io/bbolt v1.3.6
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
)

replace github.com/lightningnetwork/lnd => github.com/guggero/lnd v0.11.0-beta.rc4.0.20210726083410-a74ce5305eaa

replace github.com/lightningnetwork/lnd/kvdb => github.com/guggero/lnd/kvdb v0.0.0-20210726083410-a74ce5305eaa

// Fix incompatibility of etcd go.mod package.
// See https://github.com/etcd-io/etcd/issues/11154
replace go.etcd.io/etcd => go.etcd.io/etcd v0.5.0-alpha.5.0.20201125193152-8a03d2e9614b
replace github.com/lightningnetwork/lnd => github.com/guggero/lnd v0.11.0-beta.rc4.0.20211213093010-1807124d9195

replace github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt v3.2.2+incompatible

go 1.13
go 1.16
Loading

0 comments on commit a239f94

Please sign in to comment.