Skip to content

Commit 74837b3

Browse files
committed
staticaddr: deposit withdrawal functions
1 parent 7c0a2f0 commit 74837b3

File tree

4 files changed

+662
-0
lines changed

4 files changed

+662
-0
lines changed

staticaddr/withdraw/interface.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
GetActiveOutpoints() ([]wire.OutPoint, error)
35+
36+
AllDepositsActive(outpoints []wire.OutPoint) ([]*deposit.Deposit, bool)
37+
38+
TransitionDeposits(outpoints []wire.OutPoint, event fsm.EventType,
39+
expectedFinalState fsm.StateType) error
40+
}

staticaddr/withdraw/log.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package withdraw
2+
3+
import (
4+
"github.com/btcsuite/btclog"
5+
"github.com/lightningnetwork/lnd/build"
6+
)
7+
8+
// Subsystem defines the sub system name of this package.
9+
const Subsystem = "CLOS"
10+
11+
// log is a logger that is initialized with no output filters. This means the
12+
// package will not perform any logging by default until the caller requests it.
13+
var log btclog.Logger
14+
15+
// The default amount of logging is none.
16+
func init() {
17+
UseLogger(build.NewSubLogger(Subsystem, nil))
18+
}
19+
20+
// UseLogger uses a specified Logger to output package logging info. This should
21+
// be used in preference to SetLogWriter if the caller is also using btclog.
22+
func UseLogger(logger btclog.Logger) {
23+
log = logger
24+
}

0 commit comments

Comments
 (0)