mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-13 12:33:04 +02:00
multi: prepare for upcoming lnd v0.14.0-beta release
This commit is contained in:
parent
d5f944e3fa
commit
429b28b110
12 changed files with 40 additions and 28 deletions
|
|
@ -220,7 +220,7 @@ func getAuctionServerDialOpts(insecure bool, proxyAddress, tlsPath string,
|
|||
proxyAddress)
|
||||
torDialer := func(_ context.Context, addr string) (net.Conn, error) {
|
||||
return tor.Dial(
|
||||
addr, proxyAddress, false,
|
||||
addr, proxyAddress, false, false,
|
||||
tor.DefaultConnTimeout,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ func readAccount(sourceBucket *bbolt.Bucket,
|
|||
return deserializeAccount(bytes.NewReader(accountBytes))
|
||||
}
|
||||
|
||||
func serializeAccount(w io.Writer, a *account.Account) error {
|
||||
func serializeAccount(w *bytes.Buffer, a *account.Account) error {
|
||||
err := WriteElements(
|
||||
w, a.Value, a.Expiry, a.TraderKey, a.AuctioneerKey, a.BatchKey,
|
||||
a.Secret, a.State, a.HeightHint, a.OutPoint,
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ func getSnapshotBuckets(tx *bbolt.Tx) (*bbolt.Bucket, *bbolt.Bucket,
|
|||
return topBucket, seqBucket, indexBucket, nil
|
||||
}
|
||||
|
||||
func serializeLocalBatchSnapshot(w io.Writer, b *LocalBatchSnapshot) error {
|
||||
func serializeLocalBatchSnapshot(w *bytes.Buffer, b *LocalBatchSnapshot) error {
|
||||
// The previous batch versions had a single clearing price but because
|
||||
// we now always store the price map afterwards, we signal a new batch
|
||||
// by storing an explicit zero price.
|
||||
|
|
@ -543,7 +543,7 @@ func deserializeLocalBatchSnapshot(r io.Reader) (*LocalBatchSnapshot, error) {
|
|||
return b, nil
|
||||
}
|
||||
|
||||
func serializeAccounts(w io.Writer,
|
||||
func serializeAccounts(w *bytes.Buffer,
|
||||
accounts map[[33]byte]*account.Account) error {
|
||||
|
||||
err := WriteElements(w, uint32(len(accounts)))
|
||||
|
|
@ -594,7 +594,7 @@ func deserializeAccounts(r io.Reader) (map[[33]byte]*account.Account, error) {
|
|||
return accs, nil
|
||||
}
|
||||
|
||||
func serializeOrders(w io.Writer, orders map[order.Nonce]order.Order) error {
|
||||
func serializeOrders(w *bytes.Buffer, orders map[order.Nonce]order.Order) error {
|
||||
err := WriteElements(w, uint32(len(orders)))
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -641,7 +641,7 @@ func deserializeOrders(r io.Reader) (map[order.Nonce]order.Order, error) {
|
|||
return orders, nil
|
||||
}
|
||||
|
||||
func serializeMatchedOrder(w io.Writer, ourNonce order.Nonce,
|
||||
func serializeMatchedOrder(w *bytes.Buffer, ourNonce order.Nonce,
|
||||
m *order.MatchedOrder) error {
|
||||
|
||||
err := WriteElements(w, ourNonce, m.Order.Nonce())
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ var (
|
|||
|
||||
// WriteElements is writes each element in the elements slice to the passed
|
||||
// io.Writer using WriteElement.
|
||||
func WriteElements(w io.Writer, elements ...interface{}) error {
|
||||
func WriteElements(w *bytes.Buffer, elements ...interface{}) error {
|
||||
for _, element := range elements {
|
||||
err := WriteElement(w, element)
|
||||
if err != nil {
|
||||
|
|
@ -48,7 +48,7 @@ func WriteElements(w io.Writer, elements ...interface{}) error {
|
|||
// any element which is to be serialized. The passed io.Writer should be backed
|
||||
// by an appropriately sized byte slice, or be able to dynamically expand to
|
||||
// accommodate additional data.
|
||||
func WriteElement(w io.Writer, element interface{}) error {
|
||||
func WriteElement(w *bytes.Buffer, element interface{}) error {
|
||||
switch e := element.(type) {
|
||||
case order.NodeTier:
|
||||
return lnwire.WriteElement(w, uint32(e))
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ func copyOrder(src, dst *bbolt.Bucket, nonce order.Nonce) error {
|
|||
|
||||
// SerializeOrder binary serializes an order to a writer using the common LN
|
||||
// wire format.
|
||||
func SerializeOrder(o order.Order, w io.Writer) error {
|
||||
func SerializeOrder(o order.Order, w *bytes.Buffer) error {
|
||||
kit := o.Details()
|
||||
|
||||
// We don't have to deserialize the nonce as it's the sub bucket name.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package clientdb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
|
@ -77,7 +78,7 @@ func (e *CreatedEvent) String() string {
|
|||
// filtering.
|
||||
//
|
||||
// NOTE: This is part of the event.Event interface.
|
||||
func (e *CreatedEvent) Serialize(w io.Writer) error {
|
||||
func (e *CreatedEvent) Serialize(w *bytes.Buffer) error {
|
||||
return WriteElements(w, e.nonce)
|
||||
}
|
||||
|
||||
|
|
@ -175,7 +176,7 @@ func (e *UpdatedEvent) String() string {
|
|||
// filtering.
|
||||
//
|
||||
// NOTE: This is part of the event.Event interface.
|
||||
func (e *UpdatedEvent) Serialize(w io.Writer) error {
|
||||
func (e *UpdatedEvent) Serialize(w *bytes.Buffer) error {
|
||||
return WriteElements(w, e.nonce, e.PrevState, e.NewState, e.UnitsFilled)
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +283,7 @@ func (e *MatchEvent) String() string {
|
|||
// filtering.
|
||||
//
|
||||
// NOTE: This is part of the event.Event interface.
|
||||
func (e *MatchEvent) Serialize(w io.Writer) error {
|
||||
func (e *MatchEvent) Serialize(w *bytes.Buffer) error {
|
||||
return WriteElements(
|
||||
w, e.nonce, e.MatchState, e.UnitsFilled, e.MatchedOrder,
|
||||
e.RejectReason,
|
||||
|
|
|
|||
|
|
@ -328,6 +328,10 @@ func readMacaroon(macPath string) (grpc.DialOption, error) {
|
|||
}
|
||||
|
||||
// Now we append the macaroon credentials to the dial options.
|
||||
cred := macaroons.NewMacaroonCredential(constrainedMac)
|
||||
cred, err := macaroons.NewMacaroonCredential(constrainedMac)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating macaroon credential: %v",
|
||||
err)
|
||||
}
|
||||
return grpc.WithPerRPCCredentials(cred), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ type Event interface {
|
|||
// Serialize writes the event data to a binary storage format. This does
|
||||
// not serialize the event type as that's handled generically to allow
|
||||
// for easy filtering.
|
||||
Serialize(io.Writer) error
|
||||
Serialize(*bytes.Buffer) error
|
||||
|
||||
// Deserialize reads the event data from a binary storage format. This
|
||||
// does not deserialize the event type as that's handled generically to
|
||||
|
|
|
|||
|
|
@ -1188,7 +1188,7 @@ func (m *Manager) rejectDuplicateChannels(
|
|||
// We gather all peers from the open and pending channels.
|
||||
ctxb := context.Background()
|
||||
peers := make(map[route.Vertex]struct{})
|
||||
openChans, err := m.cfg.LightningClient.ListChannels(ctxb)
|
||||
openChans, err := m.cfg.LightningClient.ListChannels(ctxb, false, false)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing open channels: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,8 +233,8 @@ func (m *MockLightning) ListTransactions(context.Context, int32,
|
|||
}
|
||||
|
||||
// ListChannels retrieves all channels of the backing lnd node.
|
||||
func (m *MockLightning) ListChannels(context.Context) ([]lndclient.ChannelInfo,
|
||||
error) {
|
||||
func (m *MockLightning) ListChannels(context.Context, bool,
|
||||
bool) ([]lndclient.ChannelInfo, error) {
|
||||
|
||||
return m.Channels, nil
|
||||
}
|
||||
|
|
|
|||
25
macaroons.go
25
macaroons.go
|
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/lightninglabs/pool/clientdb"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/macaroons"
|
||||
"github.com/lightningnetwork/lnd/rpcperms"
|
||||
|
|
@ -193,12 +194,11 @@ var (
|
|||
// exist yet. If macaroons are disabled in general in the configuration, none of
|
||||
// these actions are taken.
|
||||
func (s *Server) startMacaroonService() error {
|
||||
// Create the macaroon authentication/authorization service.
|
||||
var err error
|
||||
s.macaroonService, err = macaroons.NewService(
|
||||
s.cfg.BaseDir, poolMacaroonLocation, false,
|
||||
clientdb.DefaultPoolDBTimeout, macaroons.IPLockChecker,
|
||||
)
|
||||
backend, err := kvdb.GetBoltBackend(&kvdb.BoltBackendConfig{
|
||||
DBPath: s.cfg.BaseDir,
|
||||
DBFileName: "macaroons.db",
|
||||
DBTimeout: clientdb.DefaultPoolDBTimeout,
|
||||
})
|
||||
if err == bbolt.ErrTimeout {
|
||||
return fmt.Errorf("error while trying to open %s/%s: "+
|
||||
"timed out after %v when trying to obtain exclusive "+
|
||||
|
|
@ -208,8 +208,15 @@ func (s *Server) startMacaroonService() error {
|
|||
clientdb.DefaultPoolDBTimeout)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to set up macaroon authentication: "+
|
||||
"%v", err)
|
||||
return fmt.Errorf("unable to load macaroon db: %v", err)
|
||||
}
|
||||
|
||||
// Create the macaroon authentication/authorization service.
|
||||
s.macaroonService, err = macaroons.NewService(
|
||||
backend, poolMacaroonLocation, false, macaroons.IPLockChecker,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to set up macaroon service: %v", err)
|
||||
}
|
||||
|
||||
// Try to unlock the macaroon store with the private password.
|
||||
|
|
@ -264,7 +271,7 @@ func (s *Server) stopMacaroonService() error {
|
|||
func (s *Server) macaroonInterceptor() (grpc.UnaryServerInterceptor,
|
||||
grpc.StreamServerInterceptor, error) {
|
||||
|
||||
interceptor := rpcperms.NewInterceptorChain(log, false)
|
||||
interceptor := rpcperms.NewInterceptorChain(log, false, nil)
|
||||
err := interceptor.Start()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
|
|
|||
|
|
@ -133,8 +133,8 @@ func (s *Server) Start() error {
|
|||
// what we need
|
||||
s.lndClient, err = lndclient.NewBasicClient(
|
||||
s.cfg.Lnd.Host, s.cfg.Lnd.TLSPath,
|
||||
path.Dir(s.cfg.Lnd.MacaroonPath), s.cfg.Network,
|
||||
lndclient.MacFilename(path.Base(s.cfg.Lnd.MacaroonPath)),
|
||||
path.Dir(s.cfg.Lnd.MacaroonPath), "", "", s.cfg.Network, false,
|
||||
false, lndclient.MacFilename(path.Base(s.cfg.Lnd.MacaroonPath)),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue