multi: update lnd dependency to v0.14.1-beta

pull/38/head v0.10.0
Oliver Gugger 2 years ago
parent 050253ec90
commit a239f944d6
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -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,

@ -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

@ -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
@ -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

@ -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()

@ -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,

@ -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`,
@ -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
}

@ -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)
@ -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()

@ -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)

@ -26,7 +26,7 @@ import (
const (
defaultAPIURL = "https://blockstream.info/api"
version = "0.9.6"
version = "0.10.0"
na = "n/a"
Commit = ""
@ -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:

@ -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"
)
@ -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
}
@ -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{

@ -125,7 +125,7 @@ func (c *PendingChannelsChannel) AsSummaryEntry() *SummaryEntry {
}
type ChannelDBFile struct {
DB *channeldb.DB
DB *channeldb.ChannelStateDB
}
func (c *ChannelDBFile) AsSummaryEntries() ([]*SummaryEntry, error) {

@ -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]

@ -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]

@ -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>

@ -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]

@ -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]

@ -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

677
go.sum

File diff suppressed because it is too large Load Diff

@ -14,7 +14,9 @@ import (
func CreateChannelBackup(db *channeldb.DB, multiFile *chanbackup.MultiFile,
ring keychain.KeyRing) error {
singles, err := chanbackup.FetchStaticChanBackups(db)
singles, err := chanbackup.FetchStaticChanBackups(
db.ChannelStateDB(), db,
)
if err != nil {
return fmt.Errorf("error extracting channel backup: %v", err)
}

@ -8,6 +8,7 @@ import (
"github.com/btcsuite/btcwallet/walletdb"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/kvdb"
"go.etcd.io/bbolt"
)
@ -27,7 +28,8 @@ func OpenDB(dbPath string, readonly bool) (*channeldb.DB, error) {
}
return channeldb.CreateWithBackend(
backend, channeldb.OptionReadOnly(readonly),
backend, channeldb.OptionSetUseGraphCache(false),
channeldb.OptionReadOnly(readonly),
)
}
@ -329,60 +331,141 @@ func (c *cursor) Seek(seek []byte) (key, value []byte) {
return (*bbolt.Cursor)(c).Seek(seek)
}
// db represents a collection of namespaces which are persisted and implements
// the walletdb.Db interface. All database access is performed through
// transactions which are obtained through the specific Namespace.
type db bbolt.DB
// backend represents a collection of namespaces which are persisted and
// implements the kvdb.Backend interface. All database access is performed
// through transactions which are obtained through the specific Namespace.
type backend struct {
db *bbolt.DB
}
// Enforce db implements the walletdb.Db interface.
var _ walletdb.DB = (*db)(nil)
// Enforce db implements the kvdb.Backend interface.
var _ kvdb.Backend = (*backend)(nil)
func (db *db) beginTx(writable bool) (*transaction, error) {
boltTx, err := (*bbolt.DB)(db).Begin(writable)
func (b *backend) beginTx(writable bool) (*transaction, error) {
boltTx, err := b.db.Begin(writable)
if err != nil {
return nil, convertErr(err)
}
return &transaction{boltTx: boltTx}, nil
}
func (db *db) BeginReadTx() (walletdb.ReadTx, error) {
return db.beginTx(false)
func (b *backend) BeginReadTx() (walletdb.ReadTx, error) {
return b.beginTx(false)
}
func (db *db) BeginReadWriteTx() (walletdb.ReadWriteTx, error) {
return db.beginTx(true)
func (b *backend) BeginReadWriteTx() (walletdb.ReadWriteTx, error) {
return b.beginTx(true)
}
// Copy writes a copy of the database to the provided writer. This call will
// start a read-only transaction to perform all operations.
//
// This function is part of the walletdb.Db interface implementation.
func (db *db) Copy(w io.Writer) error {
return convertErr((*bbolt.DB)(db).View(func(tx *bbolt.Tx) error {
// This function is part of the kvdb.Backend interface implementation.
func (b *backend) Copy(w io.Writer) error {
return convertErr(b.db.View(func(tx *bbolt.Tx) error {
return tx.Copy(w)
}))
}
// Close cleanly shuts down the database and syncs all data.
//
// This function is part of the walletdb.Db interface implementation.
func (db *db) Close() error {
return convertErr((*bbolt.DB)(db).Close())
// This function is part of the kvdb.Backend interface implementation.
func (b *backend) Close() error {
return convertErr(b.db.Close())
}
// Batch is similar to the package-level Update method, but it will attempt to
// optismitcally combine the invocation of several transaction functions into a
// optimistically combine the invocation of several transaction functions into a
// single db write transaction.
//
// This function is part of the walletdb.Db interface implementation.
func (db *db) Batch(f func(tx walletdb.ReadWriteTx) error) error {
return (*bbolt.DB)(db).Batch(func(btx *bbolt.Tx) error {
func (b *backend) Batch(f func(tx walletdb.ReadWriteTx) error) error {
return b.db.Batch(func(btx *bbolt.Tx) error {
interfaceTx := transaction{btx}
return f(&interfaceTx)
})
}
// View opens a database read transaction and executes the function f with the
// transaction passed as a parameter. After f exits, the transaction is rolled
// back. If f errors, its error is returned, not a rollback error (if any
// occur). The passed reset function is called before the start of the
// transaction and can be used to reset intermediate state. As callers may
// expect retries of the f closure (depending on the database backend used), the
// reset function will be called before each retry respectively.
func (b *backend) View(f func(tx walletdb.ReadTx) error, reset func()) error {
// We don't do any retries with bolt so we just initially call the reset
// function once.
reset()
tx, err := b.BeginReadTx()
if err != nil {
return err
}
// Make sure the transaction rolls back in the event of a panic.
defer func() {
if tx != nil {
_ = tx.Rollback()
}
}()
err = f(tx)
rollbackErr := tx.Rollback()
if err != nil {
return err
}
if rollbackErr != nil {
return rollbackErr
}
return nil
}
// Update opens a database read/write transaction and executes the function f
// with the transaction passed as a parameter. After f exits, if f did not
// error, the transaction is committed. Otherwise, if f did error, the
// transaction is rolled back. If the rollback fails, the original error
// returned by f is still returned. If the commit fails, the commit error is
// returned. As callers may expect retries of the f closure (depending on the
// database backend used), the reset function will be called before each retry
// respectively.
func (b *backend) Update(f func(tx walletdb.ReadWriteTx) error,
reset func()) error {
// We don't do any retries with bolt so we just initially call the reset
// function once.
reset()
tx, err := b.BeginReadWriteTx()
if err != nil {
return err
}
// Make sure the transaction rolls back in the event of a panic.
defer func() {
if tx != nil {
_ = tx.Rollback()
}
}()
err = f(tx)
if err != nil {
// Want to return the original error, not a rollback error if
// any occur.
_ = tx.Rollback()
return err
}
return tx.Commit()
}
// PrintStats returns all collected stats pretty printed into a string.
func (b *backend) PrintStats() string {
return "n/a"
}
// filesExists reports whether the named file or directory exists.
func fileExists(name string) bool {
if _, err := os.Stat(name); err != nil {
@ -393,10 +476,10 @@ func fileExists(name string) bool {
return true
}
// openDB opens the database at the provided path. walletdb.ErrDbDoesNotExist
// openDB opens the database at the provided path. walletdb.ErrDbDoesNotExist
// is returned if the database doesn't exist and the create flag is not set.
func openDB(dbPath string, noFreelistSync bool,
readonly bool, timeout time.Duration) (walletdb.DB, error) {
readonly bool, timeout time.Duration) (kvdb.Backend, error) {
if !fileExists(dbPath) {
return nil, walletdb.ErrDbDoesNotExist
@ -412,5 +495,5 @@ func openDB(dbPath string, noFreelistSync bool,
}
boltDB, err := bbolt.Open(dbPath, 0600, options)
return (*db)(boltDB), convertErr(err)
return &backend{db: boltDB}, convertErr(err)
}

Loading…
Cancel
Save