Skip to content

Rebase static-addr staging #739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e30cb5f
multi: apply make fmt
starius Apr 17, 2024
368432e
looprpc,swapserverrpc: update Go image to 1.21.9-bookworm
starius Apr 17, 2024
b99cde1
go: bump protobuf to v1.33.0-hex-display
starius Apr 17, 2024
bfc3f44
update aperture to include lsat to l402 renaming
starius Apr 17, 2024
0e7927a
multi: replace LSAT with L402
starius Apr 17, 2024
7bb04ae
loopd: recorgnize maxlsatcost and maxlsatfee flags
starius Apr 24, 2024
14dc8e1
looprpc: additional_bindings for /v1/lsat/tokens
starius Apr 24, 2024
5a1f795
loopd: re-add GetLsatTokens method in gRPC
starius Apr 25, 2024
13e8c29
Merge pull request #730 from starius/s-lsat-l402
bhandras Apr 29, 2024
75d7641
sweepbatcher: add more debug logging
bhandras Apr 30, 2024
e5dd7ad
Merge pull request #738 from lightninglabs/sweep-logging
bhandras Apr 30, 2024
636f8b6
daemon: fix wrapped errors and typos
hieblmi Apr 26, 2024
7a8c052
Merge pull request #736 from hieblmi/daemon-chore
hieblmi May 3, 2024
883d83a
sqlc: static address migrations, models, queries
hieblmi Nov 9, 2023
7915aab
swapserverrpc: static address creation support
hieblmi Feb 14, 2024
2afdd09
looprpc: static address creation
hieblmi Nov 9, 2023
d2a28a0
log: static address sub logger
hieblmi Nov 9, 2023
46b6dd2
loopdb: static address store
hieblmi Nov 9, 2023
9baaede
staticaddr: static address manager
hieblmi Nov 9, 2023
0178eeb
staticaddr: static address server
hieblmi Feb 14, 2024
cc97b7b
perms: static address creation permission
hieblmi Nov 9, 2023
ffec5e1
loop: static address creation client command
hieblmi Nov 9, 2023
c2a8b72
gomod: tidy
hieblmi Feb 12, 2024
2e397d5
looprpc: list unspent static address
hieblmi Nov 9, 2023
7192cdf
staticaddr: track and list spends in manager
hieblmi Oct 25, 2023
9352f17
staticaddr: list unspent outputs in server
hieblmi Oct 25, 2023
0eb787e
perms: list unspent outputs
hieblmi Oct 25, 2023
995fb65
loop: list unspent static address outputs
hieblmi Oct 25, 2023
5630f39
loop: static address creation client command
hieblmi Nov 9, 2023
34f05cc
daemon: integrate static address manager and sql store
hieblmi Nov 9, 2023
95e704a
gomod: tidy
hieblmi Apr 22, 2024
8a38b13
looprpc: include static address in swap client
hieblmi Feb 26, 2024
edfb154
sqlc: deposit queries, models and migrations
hieblmi Mar 7, 2024
246d4dd
istaticaddr: interfaces
hieblmi Mar 7, 2024
2b3b3a8
staticaddr: deposit logger
hieblmi Mar 7, 2024
0e1b4dc
staticaddr: deposit manager and fsm
hieblmi Mar 7, 2024
aaa86f7
staticaddr: deposits for server and daemon
hieblmi Mar 7, 2024
45f9b6a
staticaddr: add swap client to cmd
hieblmi Mar 7, 2024
239f6b4
unit: manager tests
hieblmi Apr 23, 2024
7c17c27
staticaddr: public deposit method scope
hieblmi Apr 25, 2024
ce6c2e7
Merge branch 'static-addr-staging' into static-addr-staging
hieblmi May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ func NewClient(dbDir string, loopDB loopdb.SwapStore,
LndServices: cfg.Lnd,
Server: swapServerClient,
Conn: swapServerClient.conn,
Store: loopDB,
L402Store: l402Store,
Store: loopDB,
CreateExpiryTimer: func(d time.Duration) <-chan time.Time {
return time.NewTimer(d).C
},
Expand Down
24 changes: 12 additions & 12 deletions loopd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type ListenerCfg struct {
// on the passed TLS configuration.
restListener func(*tls.Config) (net.Listener, error)

// getLnd returns a grpc connection to an lnd instance.
// getLnd returns a grpc connection to a lnd instance.
getLnd func(lndclient.Network, *lndConfig) (*lndclient.GrpcLndServices,
error)
}
Expand Down Expand Up @@ -120,9 +120,9 @@ func New(config *Config, lisCfg *ListenerCfg) *Daemon {
// Start starts loopd in daemon mode. It will listen for grpc connections,
// execute commands and pass back swap status information.
func (d *Daemon) Start() error {
// There should be no reason to start the daemon twice. Therefore return
// an error if that's tried. This is mostly to guard against Start and
// StartAsSubserver both being called.
// There should be no reason to start the daemon twice. Therefore,
// return an error if that's tried. This is mostly to guard against
// Start and StartAsSubserver both being called.
if atomic.AddInt32(&d.started, 1) != 1 {
return errOnlyStartOnce
}
Expand All @@ -137,7 +137,7 @@ func (d *Daemon) Start() error {

// With lnd connected, initialize everything else, such as the swap
// server client, the swap client RPC server instance and our main swap
// and error handlers. If this fails, then nothing has been started yet
// and error handlers. If this fails, then nothing has been started yet,
// and we can just return the error.
err = d.initialize(true)
if errors.Is(err, bbolt.ErrTimeout) {
Expand Down Expand Up @@ -324,7 +324,7 @@ func (d *Daemon) startWebServers() error {
err := d.restServer.Serve(d.restListener)
// ErrServerClosed is always returned when the proxy is
// shut down, so don't log it.
if err != nil && err != http.ErrServerClosed {
if err != nil && !errors.Is(err, http.ErrServerClosed) {
// Notify the main error handler goroutine that
// we exited unexpectedly here. We don't have to
// worry about blocking as the internal error
Expand All @@ -343,7 +343,7 @@ func (d *Daemon) startWebServers() error {

log.Infof("RPC server listening on %s", d.grpcListener.Addr())
err = d.grpcServer.Serve(d.grpcListener)
if err != nil && err != grpc.ErrServerStopped {
if err != nil && !errors.Is(err, grpc.ErrServerStopped) {
// Notify the main error handler goroutine that
// we exited unexpectedly here. We don't have to
// worry about blocking as the internal error
Expand Down Expand Up @@ -719,9 +719,9 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
var runtimeErr error

// There are only two ways this goroutine can exit. Either there
// is an internal error or the caller requests shutdown. In both
// cases we wait for the stop to complete before we signal the
// caller that we're done.
// is an internal error or the caller requests a shutdown.
// In both cases we wait for the stop to complete before we
// signal the caller that we're done.
select {
case runtimeErr = <-d.internalErrChan:
log.Errorf("Runtime error in daemon, shutting down: "+
Expand All @@ -730,7 +730,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
case <-d.quit:
}

// We need to shutdown before sending the error on the channel,
// We need to shut down before sending the error on the channel,
// otherwise a caller might exit the process too early.
d.stop()
cleanupMacaroonStore()
Expand Down Expand Up @@ -761,7 +761,7 @@ func (d *Daemon) stop() {
d.mainCtxCancel()
}

// As there is no swap activity anymore, we can forcefully shutdown the
// As there is no swap activity anymore, we can forcefully shut down the
// gRPC and HTTP servers now.
log.Infof("Stopping gRPC server")
if d.grpcServer != nil {
Expand Down
28 changes: 22 additions & 6 deletions sweepbatcher/sweep_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sweepbatcher
import (
"bytes"
"context"
"encoding/hex"
"fmt"
"math"
"sync"
Expand Down Expand Up @@ -700,9 +701,11 @@ func (b *batch) publishBatch(ctx context.Context) (btcutil.Amount, error) {
batchTx.TxIn[i].Witness = witness
}

b.log.Debugf("attempting to publish non-coop tx with feerate=%v, "+
"totalfee=%v, sweeps=%v, destAddr=%s", b.rbfCache.FeeRate, fee,
len(batchTx.TxIn), address.String())
b.log.Infof("attempting to publish non-coop tx=%v with feerate=%v, "+
"totalfee=%v, sweeps=%d, destAddr=%s", batchTx.TxHash(),
b.rbfCache.FeeRate, fee, len(batchTx.TxIn), address)

b.debugLogTx("serialized non-coop sweep", batchTx)

err = b.wallet.PublishTransaction(
ctx, batchTx, labels.LoopOutBatchSweepSuccess(b.id),
Expand Down Expand Up @@ -846,9 +849,11 @@ func (b *batch) publishBatchCoop(ctx context.Context) (btcutil.Amount,
return fee, err, false
}

b.log.Debugf("attempting to publish coop tx with feerate=%v, "+
"totalfee=%v, sweeps=%v, destAddr=%s", b.rbfCache.FeeRate, fee,
len(batchTx.TxIn), address.String())
b.log.Infof("attempting to publish coop tx=%v with feerate=%v, "+
"totalfee=%v, sweeps=%d, destAddr=%s", batchTx.TxHash(),
b.rbfCache.FeeRate, fee, len(batchTx.TxIn), address)

b.debugLogTx("serialized coop sweep", batchTx)

err = b.wallet.PublishTransaction(
ctx, batchTx, labels.LoopOutBatchSweepSuccess(b.id),
Expand All @@ -866,6 +871,17 @@ func (b *batch) publishBatchCoop(ctx context.Context) (btcutil.Amount,
return fee, nil, true
}

func (b *batch) debugLogTx(msg string, tx *wire.MsgTx) {
// Serialize the transaction and convert to hex string.
buf := bytes.NewBuffer(make([]byte, 0, tx.SerializeSize()))
if err := tx.Serialize(buf); err != nil {
b.log.Errorf("failed to serialize tx for debug log: %v", err)
return
}

b.log.Debugf("%s: %s", msg, hex.EncodeToString(buf.Bytes()))
}

// coopSignBatchTx collects the necessary signatures from the server in order
// to cooperatively sweep the funds.
func (b *batch) coopSignBatchTx(ctx context.Context, packet *psbt.Packet,
Expand Down