@@ -11,6 +11,33 @@ import (
1111 "github.com/lightninglabs/taproot-assets/commitment"
1212)
1313
14+ // GenConfig is a struct that holds the configuration for creating Taproot Asset
15+ // proofs.
16+ type GenConfig struct {
17+ // transitionVersion is the version of the asset state transition proof
18+ // that is going to be used.
19+ transitionVersion TransitionVersion
20+ }
21+
22+ // DefaultGenConfig returns a default proof generation configuration.
23+ func DefaultGenConfig () GenConfig {
24+ return GenConfig {
25+ transitionVersion : TransitionV0 ,
26+ }
27+ }
28+
29+ // GenOption is a function type that can be used to modify the proof generation
30+ // configuration.
31+ type GenOption func (* GenConfig )
32+
33+ // WithVersion is an option that can be used to create a transition proof of the
34+ // given version.
35+ func WithVersion (v TransitionVersion ) GenOption {
36+ return func (cfg * GenConfig ) {
37+ cfg .transitionVersion = v
38+ }
39+ }
40+
1441// TransitionParams holds the set of chain level information needed to append a
1542// proof to an existing file for the given asset state transition.
1643type TransitionParams struct {
@@ -42,8 +69,8 @@ type TransitionParams struct {
4269// on-chain output, this function takes the script key of the asset to return
4370// the proof for. This method returns both the encoded full provenance (proof
4471// chain) and the added latest proof.
45- func AppendTransition (blob Blob , params * TransitionParams ,
46- vCtx VerifierCtx ) (Blob , * Proof , error ) {
72+ func AppendTransition (blob Blob , params * TransitionParams , vCtx VerifierCtx ,
73+ opts ... GenOption ) (Blob , * Proof , error ) {
4774
4875 // Decode the proof blob into a proper file structure first.
4976 f := NewEmptyFile (V0 )
@@ -69,7 +96,7 @@ func AppendTransition(blob Blob, params *TransitionParams,
6996 }
7097
7198 // We can now create the new proof entry for the asset in the params.
72- newProof , err := CreateTransitionProof (lastPrevOut , params )
99+ newProof , err := CreateTransitionProof (lastPrevOut , params , opts ... )
73100 if err != nil {
74101 return nil , nil , fmt .Errorf ("error creating transition " +
75102 "proof: %w" , err )
@@ -122,10 +149,17 @@ func (p *Proof) UpdateTransitionProof(params *BaseProofParams) error {
122149
123150// CreateTransitionProof creates a proof for an asset transition, based on the
124151// last proof of the last asset state and the new asset in the params.
125- func CreateTransitionProof (prevOut wire.OutPoint ,
126- params * TransitionParams ) (* Proof , error ) {
152+ func CreateTransitionProof (prevOut wire.OutPoint , params * TransitionParams ,
153+ opts ... GenOption ) (* Proof , error ) {
127154
128- proof , err := baseProof (& params .BaseProofParams , prevOut )
155+ cfg := DefaultGenConfig ()
156+ for _ , opt := range opts {
157+ opt (& cfg )
158+ }
159+
160+ proof , err := baseProof (
161+ & params .BaseProofParams , prevOut , cfg .transitionVersion ,
162+ )
129163 if err != nil {
130164 return nil , fmt .Errorf ("error creating base proofs: %w" , err )
131165 }
0 commit comments