Skip to content

Commit

Permalink
fix(BUX-250): fix scripts veryfication in spv
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszos4chain committed Nov 14, 2023
1 parent 3bb2a00 commit 9c3facd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions p2p_spv.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ func verifyMerkleRoots(dBeef *DecodedBEEF, provider MerkleRootVerifier) error {
}

func validateScripts(dBeef *DecodedBEEF) error {
for _, input := range dBeef.ProcessedTxData.Inputs {
txID := input.PreviousTxIDStr()
for j, input2 := range dBeef.InputsTxData {
if input2.Transaction.TxID() == txID {
result := verifyScripts(dBeef.ProcessedTxData, input2.Transaction, j)
if !result {
return errors.New("invalid script")
}
break
}
for i, input := range dBeef.ProcessedTxData.Inputs {
inputParentTx := findParentForInput(input, dBeef.InputsTxData)
if inputParentTx == nil {
return errors.New("invalid parent transactions, no matching trasactions for input")
}

result := verifyScripts(dBeef.ProcessedTxData, inputParentTx.Transaction, i)
if !result {
return errors.New("invalid script")
}
}

return nil
}

Expand Down

0 comments on commit 9c3facd

Please sign in to comment.