Skip to content

Commit

Permalink
change condition in deletion (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
charymalloju authored Nov 12, 2024
2 parents bb68897 + ab16d95 commit 0e2151e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/handler/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ func (h *Handler) DeleteTransaction(c echo.Context) error {
// Fetch signed_at before attempting to delete, to avoid issues if the transaction does not exist
var signedAt time.Time
var status string
err = h.DB.QueryRow(`SELECT signed_at,status FROM transactions WHERE id=$1 AND multisig_address=$2`, txId, address).Scan(&signedAt, &status)
var transaction schema.Transaction
err = h.DB.QueryRow(`SELECT signed_at,status, signatures FROM transactions WHERE id=$1 AND multisig_address=$2`, txId, address).Scan(&signedAt, &status, &transaction.Signatures)
if err != nil {
if err == sql.ErrNoRows {
return c.JSON(http.StatusNotFound, model.ErrorResponse{
Expand All @@ -545,8 +546,8 @@ func (h *Handler) DeleteTransaction(c echo.Context) error {
}

// Clear signatures for transactions with signed_at > txSignedAt
if !signedAt.IsZero() && status == "PENDING" {
_, err = h.DB.Exec(`UPDATE transactions SET signatures='[]'::jsonb WHERE multisig_address=$1 AND signed_at > $2 and status='PENDING'`, address, signedAt)
if !signedAt.IsZero() && status == "PENDING" && len(transaction.Signatures) > 0 {
_, err = h.DB.Exec(`UPDATE transactions SET signatures='[]'::jsonb, signed_at = '0001-01-01 00:00:00' WHERE multisig_address=$1 AND signed_at > $2 and status='PENDING'`, address, signedAt)
if err != nil {
return c.JSON(http.StatusInternalServerError, model.ErrorResponse{
Status: "error",
Expand Down

0 comments on commit 0e2151e

Please sign in to comment.