mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-07 19:30:46 +02:00
cnct: add new methods for resolvers
This commit is contained in:
@@ -5,11 +5,12 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/invoices"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
// htlcIncomingContestResolver is a ContractResolver that's able to resolve an
|
||||
@@ -34,6 +35,24 @@ type htlcIncomingContestResolver struct {
|
||||
htlcSuccessResolver
|
||||
}
|
||||
|
||||
// newIncomingContestResolver instantiates a new incoming htlc contest resolver.
|
||||
func newIncomingContestResolver(htlcExpiry uint32,
|
||||
circuitKey channeldb.CircuitKey, res lnwallet.IncomingHtlcResolution,
|
||||
broadcastHeight uint32, payHash lntypes.Hash,
|
||||
htlcAmt lnwire.MilliSatoshi,
|
||||
resCfg ResolverConfig) *htlcIncomingContestResolver {
|
||||
|
||||
success := newSuccessResolver(
|
||||
res, broadcastHeight, payHash, htlcAmt, resCfg,
|
||||
)
|
||||
|
||||
return &htlcIncomingContestResolver{
|
||||
htlcExpiry: htlcExpiry,
|
||||
circuitKey: circuitKey,
|
||||
htlcSuccessResolver: *success,
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve attempts to resolve this contract. As we don't yet know of the
|
||||
// preimage for the contract, we'll wait for one of two things to happen:
|
||||
//
|
||||
@@ -319,15 +338,6 @@ func newIncomingContestResolverFromReader(r io.Reader, resCfg ResolverConfig) (
|
||||
return h, nil
|
||||
}
|
||||
|
||||
// AttachConfig should be called once a resolved is successfully decoded from
|
||||
// its stored format. This struct delivers the configuration items that
|
||||
// resolvers need to complete their duty.
|
||||
//
|
||||
// NOTE: Part of the ContractResolver interface.
|
||||
func (h *htlcIncomingContestResolver) AttachConfig(r ResolverConfig) {
|
||||
h.htlcSuccessResolver.AttachConfig(r)
|
||||
}
|
||||
|
||||
// A compile time assertion to ensure htlcIncomingContestResolver meets the
|
||||
// ContractResolver interface.
|
||||
var _ ContractResolver = (*htlcIncomingContestResolver)(nil)
|
||||
|
Reference in New Issue
Block a user