@@ -96,14 +96,13 @@ def __init__(self, contract: Union[StandardP2TR, StandardAugmentedP2TR]):
96
96
self .outpoint : Optional [COutPoint ] = None
97
97
self .funding_tx : Optional [CTransaction ] = None
98
98
99
+ # The following fields are filled when the instance is spent
99
100
self .spending_tx : Optional [CTransaction ] = None
100
- self .spending_vin = None
101
-
102
- self .spending_clause = None
103
- self .spending_args = None
104
-
105
- # Once spent, the list of ContractInstances produced
106
- self .next = None
101
+ self .spending_vin : Optional [int ] = None
102
+ self .spending_clause : Optional [str ] = None
103
+ self .spending_args : Optional [dict ] = None
104
+ # the new instances produced by spending this instance
105
+ self .next : Optional [List [ContractInstance ]] = None
107
106
108
107
def is_augm (self ) -> bool :
109
108
"""
@@ -580,13 +579,16 @@ def wait_for_spend(self, instances: Union[ContractInstance, List[ContractInstanc
580
579
# and add them to the manager if they are standard
581
580
if isinstance (next_outputs , CTransaction ):
582
581
# For now, we assume CTV clauses are terminal;
583
- # this might be generalized in the future
582
+ # this might be generalized in the future to support tracking
583
+ # known output contracts in a CTV template
584
584
pass
585
585
else :
586
+ next_instances : List [ContractInstance ] = []
586
587
for clause_output in next_outputs :
587
588
output_index = vin if clause_output .n == - 1 else clause_output .n
588
589
589
590
if output_index in out_contracts :
591
+ next_instances .append (out_contracts [output_index ])
590
592
continue # output already specified by another input
591
593
592
594
out_contract = clause_output .next_contract
@@ -610,6 +612,9 @@ def wait_for_spend(self, instances: Union[ContractInstance, List[ContractInstanc
610
612
611
613
out_contracts [output_index ] = new_instance
612
614
615
+ next_instances .append (new_instance )
616
+ instance .next = next_instances
617
+
613
618
result = list (out_contracts .values ())
614
619
for instance in result :
615
620
self .add_instance (instance )
0 commit comments