Skip to content

Commit 1685847

Browse files
committed
staticaddr: open channel manager
1 parent 279f890 commit 1685847

File tree

6 files changed

+920
-4
lines changed

6 files changed

+920
-4
lines changed

staticaddr/log.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/lightninglabs/loop/staticaddr/address"
66
"github.com/lightninglabs/loop/staticaddr/deposit"
77
"github.com/lightninglabs/loop/staticaddr/loopin"
8+
"github.com/lightninglabs/loop/staticaddr/openchannel"
89
"github.com/lightninglabs/loop/staticaddr/withdraw"
910
"github.com/lightningnetwork/lnd/build"
1011
)
@@ -29,4 +30,5 @@ func UseLogger(logger btclog.Logger) {
2930
deposit.UseLogger(log)
3031
withdraw.UseLogger(log)
3132
loopin.UseLogger(log)
33+
openchannel.UseLogger(log)
3234
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package openchannel
2+
3+
import (
4+
"context"
5+
6+
"github.com/btcsuite/btcd/btcutil"
7+
"github.com/btcsuite/btcd/wire"
8+
"github.com/lightninglabs/loop/fsm"
9+
"github.com/lightninglabs/loop/staticaddr/address"
10+
"github.com/lightninglabs/loop/staticaddr/deposit"
11+
"github.com/lightninglabs/loop/staticaddr/script"
12+
)
13+
14+
// AddressManager handles fetching of address parameters.
15+
type AddressManager interface {
16+
// GetStaticAddressParameters returns the static address parameters.
17+
GetStaticAddressParameters(ctx context.Context) (*address.Parameters,
18+
error)
19+
20+
// GetStaticAddress returns the deposit address for the given
21+
// client and server public keys.
22+
GetStaticAddress(ctx context.Context) (*script.StaticAddress, error)
23+
}
24+
25+
type DepositManager interface {
26+
// AllOutpointsActiveDeposits returns all deposits that are in the
27+
// given state. If the state filter is fsm.StateTypeNone, all deposits
28+
// are returned.
29+
AllOutpointsActiveDeposits(outpoints []wire.OutPoint,
30+
stateFilter fsm.StateType) ([]*deposit.Deposit, bool)
31+
32+
// GetActiveDepositsInState returns all deposits that are in the
33+
// given state.
34+
GetActiveDepositsInState(stateFilter fsm.StateType) ([]*deposit.Deposit,
35+
error)
36+
37+
// TransitionDeposits transitions the deposits to the given state.
38+
TransitionDeposits(ctx context.Context, deposits []*deposit.Deposit,
39+
event fsm.EventType, expectedFinalState fsm.StateType) error
40+
}
41+
42+
type WithdrawalManager interface {
43+
CreateFinalizedWithdrawalTx(ctx context.Context,
44+
deposits []*deposit.Deposit, withdrawalAddress btcutil.Address,
45+
satPerVbyte int64, selectedWithdrawalAmount int64) (*wire.MsgTx,
46+
[]byte, error)
47+
}

staticaddr/openchannel/log.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package openchannel
2+
3+
import (
4+
"github.com/btcsuite/btclog/v2"
5+
"github.com/lightningnetwork/lnd/build"
6+
)
7+
8+
// Subsystem defines the sub system name of this package.
9+
const Subsystem = "SCHOPEN"
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)