Skip to content

Commit 4908d76

Browse files
committed
protofsm: add option to allow conf resp to return full back
In this commit, we add an option to allow a conf req caller to receive the full block. This is useful if the caller wants to be able to create an SPV proof.
1 parent a893077 commit 4908d76

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

protofsm/daemon_events.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ type RegisterConf[Event any] struct {
116116
// transaction needs to dispatch an event.
117117
NumConfs fn.Option[uint32]
118118

119+
// FullBlock is a boolean that indicates whether we want the full block
120+
// in the returned response. This is useful if callers want to create an
121+
// SPV proof for the transaction post conf.
122+
FullBlock bool
123+
119124
// PostConfMapper is a special conf mapper, that if present, will be
120125
// used to map the protofsm confirmation event to a custom event.
121126
PostConfMapper fn.Option[ConfMapper[Event]]

protofsm/state_machine.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,15 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent(ctx context.Context,
510510
s.log.DebugS(ctx, "Registering conf",
511511
"txid", daemonEvent.Txid)
512512

513+
var opts []chainntnfs.NotifierOption
514+
if daemonEvent.FullBlock {
515+
opts = append(opts, chainntnfs.WithIncludeBlock())
516+
}
517+
513518
numConfs := daemonEvent.NumConfs.UnwrapOr(1)
514519
confEvent, err := s.cfg.Daemon.RegisterConfirmationsNtfn(
515520
&daemonEvent.Txid, daemonEvent.PkScript,
516-
numConfs, daemonEvent.HeightHint,
521+
numConfs, daemonEvent.HeightHint, opts...,
517522
)
518523
if err != nil {
519524
return fmt.Errorf("unable to register conf: %w", err)

0 commit comments

Comments
 (0)