Skip to content

Commit 5d26625

Browse files
committed
staticaddr: withdrawal manager and interface
1 parent 62087ad commit 5d26625

File tree

4 files changed

+793
-0
lines changed

4 files changed

+793
-0
lines changed

staticaddr/log.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/btcsuite/btclog"
55
"github.com/lightninglabs/loop/staticaddr/address"
66
"github.com/lightninglabs/loop/staticaddr/deposit"
7+
"github.com/lightninglabs/loop/staticaddr/withdraw"
78
"github.com/lightningnetwork/lnd/build"
89
)
910

@@ -25,4 +26,5 @@ func UseLogger(logger btclog.Logger) {
2526
log = logger
2627
address.UseLogger(log)
2728
deposit.UseLogger(log)
29+
withdraw.UseLogger(log)
2830
}

staticaddr/withdraw/interface.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package withdraw
2+
3+
import (
4+
"context"
5+
6+
"github.com/btcsuite/btcd/wire"
7+
"github.com/lightninglabs/loop/fsm"
8+
"github.com/lightninglabs/loop/staticaddr/address"
9+
"github.com/lightninglabs/loop/staticaddr/deposit"
10+
"github.com/lightninglabs/loop/staticaddr/script"
11+
"github.com/lightningnetwork/lnd/lnwallet"
12+
)
13+
14+
const (
15+
IdLength = 32
16+
)
17+
18+
// AddressManager handles fetching of address parameters.
19+
type AddressManager interface {
20+
// GetStaticAddressParameters returns the static address parameters.
21+
GetStaticAddressParameters(ctx context.Context) (*address.Parameters,
22+
error)
23+
24+
// GetStaticAddress returns the deposit address for the given
25+
// client and server public keys.
26+
GetStaticAddress(ctx context.Context) (*script.StaticAddress, error)
27+
28+
// ListUnspent returns a list of utxos at the static address.
29+
ListUnspent(ctx context.Context, minConfs,
30+
maxConfs int32) ([]*lnwallet.Utxo, error)
31+
}
32+
33+
type DepositManager interface {
34+
GetActiveDepositsInState(stateFilter fsm.StateType) ([]*deposit.Deposit,
35+
error)
36+
37+
AllOutpointsActiveDeposits(outpoints []wire.OutPoint,
38+
stateFilter fsm.StateType) ([]*deposit.Deposit, bool)
39+
40+
TransitionDeposits(deposits []*deposit.Deposit, event fsm.EventType,
41+
expectedFinalState fsm.StateType) error
42+
43+
UpdateDeposit(d *deposit.Deposit) error
44+
}

staticaddr/withdraw/log.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package withdraw
2+
3+
import (
4+
"github.com/btcsuite/btclog"
5+
)
6+
7+
// log is a logger that is initialized with no output filters. This means the
8+
// package will not perform any logging by default until the caller requests it.
9+
var log btclog.Logger
10+
11+
// UseLogger uses a specified Logger to output package logging info. This should
12+
// be used in preference to SetLogWriter if the caller is also using btclog.
13+
func UseLogger(logger btclog.Logger) {
14+
log = logger
15+
}

0 commit comments

Comments
 (0)