protofsm: add daemon events for spend+conf registration
This commit is contained in:
3 files changed
+186
-1
No files matched your search
@@ -2,6 +2,7 @@ package protofsm
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -21,7 +22,8 @@ type DaemonEventSet []DaemonEvent
|
||||
// DaemonEvents is a special type constraint that enumerates all the possible
|
||||
// types of daemon events.
|
||||
type DaemonEvents interface {
|
||||
SendMsgEvent[any] | BroadcastTxn
|
||||
SendMsgEvent[any] | BroadcastTxn | RegisterSpend[any] |
|
||||
RegisterConf[any]
|
||||
}
|
||||
|
||||
// SendPredicate is a function that returns true if the target message should
|
||||
@@ -64,3 +66,53 @@ type BroadcastTxn struct {
|
||||
|
||||
// daemonSealed indicates that this struct is a DaemonEvent instance.
|
||||
func (b *BroadcastTxn) daemonSealed() {}
|
||||
|
||||
// RegisterSpend is used to request that a certain event is sent into the state
|
||||
// machien once the specified outpoint has been spent.
|
||||
type RegisterSpend[Event any] struct {
|
||||
// OutPoint is the outpoint on chain to watch.
|
||||
OutPoint wire.OutPoint
|
||||
|
||||
// PkScript is the script that we expect to be spent along with the
|
||||
// outpoint.
|
||||
PkScript []byte
|
||||
|
||||
// HeightHint is a value used to give the chain scanner a hint on how
|
||||
// far back it needs to start its search.
|
||||
HeightHint uint32
|
||||
|
||||
// PostSpendEvent is an event that's sent back to the requester once a
|
||||
// transaction spending the outpoint has been confirmed in the main
|
||||
// chain.
|
||||
PostSpendEvent fn.Option[Event]
|
||||
}
|
||||
|
||||
// daemonSealed indicates that this struct is a DaemonEvent instance.
|
||||
func (r *RegisterSpend[E]) daemonSealed() {}
|
||||
|
||||
// RegisterConf is used to request that a certain event is sent into the state
|
||||
// machien once the specified outpoint has been spent.
|
||||
type RegisterConf[Event any] struct {
|
||||
// Txid is the txid of the txn we want to watch the chain for.
|
||||
Txid chainhash.Hash
|
||||
|
||||
// PkScript is the script that we expect to be created along with the
|
||||
// outpoint.
|
||||
PkScript []byte
|
||||
|
||||
// HeightHint is a value used to give the chain scanner a hint on how
|
||||
// far back it needs to start its search.
|
||||
HeightHint uint32
|
||||
|
||||
// NumConfs is the number of confirmations that the spending
|
||||
// transaction needs to dispatch an event.
|
||||
NumConfs fn.Option[uint32]
|
||||
|
||||
// PostConfEvent is an event that's sent back to the requester once the
|
||||
// transaction specified above has confirmed in the chain with
|
||||
// sufficient depth.
|
||||
PostConfEvent fn.Option[Event]
|
||||
}
|
||||
|
||||
// daemonSealed indicates that this struct is a DaemonEvent instance.
|
||||
func (r *RegisterConf[E]) daemonSealed() {}
|
||||
Reference in new issue
Block a user