mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
instantout: add addr to send funds to
This commit is contained in:
parent
c19781bd13
commit
6a62be0d09
6 changed files with 233 additions and 187 deletions
|
|
@ -19,6 +19,7 @@ import (
|
|||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -59,6 +60,7 @@ type InitInstantOutCtx struct {
|
|||
initationHeight int32
|
||||
outgoingChanSet loopdb.ChannelSet
|
||||
protocolVersion ProtocolVersion
|
||||
sweepAddress btcutil.Address
|
||||
}
|
||||
|
||||
// InitInstantOutAction is the first action that is executed when the instant
|
||||
|
|
@ -165,11 +167,15 @@ func (f *FSM) InitInstantOutAction(eventCtx fsm.EventContext) fsm.EventType {
|
|||
}
|
||||
|
||||
// Create the address that we'll send the funds to.
|
||||
sweepAddress, err := f.cfg.Wallet.NextAddr(
|
||||
f.ctx, "", walletrpc.AddressType_TAPROOT_PUBKEY, false,
|
||||
)
|
||||
if err != nil {
|
||||
return f.HandleError(err)
|
||||
sweepAddress := initCtx.sweepAddress
|
||||
if sweepAddress == nil {
|
||||
sweepAddress, err = f.cfg.Wallet.NextAddr(
|
||||
f.ctx, lnwallet.DefaultAccountName,
|
||||
walletrpc.AddressType_TAPROOT_PUBKEY, false,
|
||||
)
|
||||
if err != nil {
|
||||
return f.HandleError(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Now we can create the instant out.
|
||||
|
|
|
|||
|
|
@ -137,7 +137,20 @@ func (m *Manager) recoverInstantOuts(ctx context.Context) error {
|
|||
|
||||
// NewInstantOut creates a new instantout.
|
||||
func (m *Manager) NewInstantOut(ctx context.Context,
|
||||
reservations []reservation.ID) (*FSM, error) {
|
||||
reservations []reservation.ID, sweepAddress string) (*FSM, error) {
|
||||
|
||||
var (
|
||||
sweepAddr btcutil.Address
|
||||
err error
|
||||
)
|
||||
if sweepAddress != "" {
|
||||
sweepAddr, err = btcutil.DecodeAddress(
|
||||
sweepAddress, m.cfg.Network,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
m.Lock()
|
||||
// Create the instantout request.
|
||||
|
|
@ -146,6 +159,7 @@ func (m *Manager) NewInstantOut(ctx context.Context,
|
|||
reservations: reservations,
|
||||
initationHeight: m.currentHeight,
|
||||
protocolVersion: CurrentProtocolVersion(),
|
||||
sweepAddress: sweepAddr,
|
||||
}
|
||||
|
||||
instantOut, err := NewFSM(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue