From c18d8497670812ebc7355b7be7b853b6603c7667 Mon Sep 17 00:00:00 2001 From: Krzysztof Tomecki <152964795+chris-4chain@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:59:51 +0200 Subject: [PATCH] fix(SPV-000): proper error on SPV failure --- errors/definitions.go | 3 +++ server/p2p_receive_transaction.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/errors/definitions.go b/errors/definitions.go index 0dc39e4..cc52547 100644 --- a/errors/definitions.go +++ b/errors/definitions.go @@ -134,4 +134,7 @@ var ( // ErrNoMatchingTransactionsForInput is when no matching transaction for input can be found ErrNoMatchingTransactionsForInput = SPVError{Message: "invalid parent transactions, no matching transactions for input", StatusCode: 417, Code: "error-spv-bump-ancestor-not-present"} + + // ErrSPVFailed is when the SPV returns an error + ErrSPVFailed = SPVError{Message: "simplified payment verification has failed", StatusCode: 417, Code: "error-spv-failed"} ) diff --git a/server/p2p_receive_transaction.go b/server/p2p_receive_transaction.go index f6a2044..cc85b85 100644 --- a/server/p2p_receive_transaction.go +++ b/server/p2p_receive_transaction.go @@ -93,7 +93,7 @@ func (c *Configuration) p2pReceiveBeefTx(context *gin.Context) { err = spv.ExecuteSimplifiedPaymentVerification(context.Request.Context(), dBeef, c.actions) if err != nil { - errors.ErrorResponse(context, errors.ErrNoOutputs) + errors.ErrorResponse(context, errors.ErrSPVFailed) return }