@@ -1942,7 +1942,7 @@ func (a *covenantlessArkClient) handleRoundFinalization(
1942
1942
boardingUtxos []types.Utxo ,
1943
1943
receivers []client.Output ,
1944
1944
) ([]string , string , error ) {
1945
- if err := a .validateVtxoTree (event , receivers , len ( vtxos ) > 0 ); err != nil {
1945
+ if err := a .validateVtxoTree (event , receivers , vtxos ); err != nil {
1946
1946
return nil , "" , fmt .Errorf ("failed to verify vtxo tree: %s" , err )
1947
1947
}
1948
1948
@@ -2031,7 +2031,7 @@ func (a *covenantlessArkClient) handleRoundFinalization(
2031
2031
}
2032
2032
2033
2033
func (a * covenantlessArkClient ) validateVtxoTree (
2034
- event client.RoundFinalizationEvent , receivers []client.Output , needConnector bool ,
2034
+ event client.RoundFinalizationEvent , receivers []client.Output , vtxosInput []client. TapscriptsVtxo ,
2035
2035
) error {
2036
2036
roundTx := event .Tx
2037
2037
ptx , err := psbt .NewFromRawBytes (strings .NewReader (roundTx ), true )
@@ -2053,7 +2053,7 @@ func (a *covenantlessArkClient) validateVtxoTree(
2053
2053
return err
2054
2054
}
2055
2055
2056
- if needConnector {
2056
+ if len ( vtxosInput ) > 0 {
2057
2057
root , err := event .Connectors .Root ()
2058
2058
if err != nil {
2059
2059
return err
@@ -2072,7 +2072,19 @@ func (a *covenantlessArkClient) validateVtxoTree(
2072
2072
return fmt .Errorf ("root's parent txid is not the same as the round txid: %s != %s" , root .ParentTxid , getTxID (roundTx ))
2073
2073
}
2074
2074
2075
- return event .Connectors .Validate (getTxID )
2075
+ if err := event .Connectors .Validate (getTxID ); err != nil {
2076
+ return err
2077
+ }
2078
+
2079
+ if len (event .ConnectorsIndex ) == 0 {
2080
+ return fmt .Errorf ("empty connectors index" )
2081
+ }
2082
+
2083
+ for _ , vtxo := range vtxosInput {
2084
+ if _ , ok := event .ConnectorsIndex [vtxo .Outpoint .String ()]; ! ok {
2085
+ return fmt .Errorf ("missing connector index for vtxo %s" , vtxo .String ())
2086
+ }
2087
+ }
2076
2088
}
2077
2089
2078
2090
return nil
@@ -2205,10 +2217,7 @@ func (a *covenantlessArkClient) createAndSignForfeits(
2205
2217
signedForfeits := make ([]string , 0 , len (vtxosToSign ))
2206
2218
2207
2219
for _ , vtxo := range vtxosToSign {
2208
- connectorOutpoint , ok := connectorsIndex [vtxo .Outpoint .String ()]
2209
- if ! ok {
2210
- return nil , fmt .Errorf ("connector index not found for vtxo %s" , vtxo .Outpoint .String ())
2211
- }
2220
+ connectorOutpoint := connectorsIndex [vtxo .Outpoint .String ()]
2212
2221
2213
2222
var connector * wire.TxOut
2214
2223
for _ , node := range connectorsTxs {
0 commit comments