mirror of
https://github.com/alexgo-io/gaze-indexer.git
synced 2026-01-12 22:43:22 +08:00
feat(btc): handling critical case for insert duplicate utxo spent
Co-authored-by: Gaze <gazenw@users.noreply.github.com>
This commit is contained in:
@@ -18,7 +18,7 @@ INSERT INTO bitcoin_transaction_txouts ("tx_hash","tx_idx","pkscript","value") V
|
||||
WITH update_txout AS (
|
||||
UPDATE "bitcoin_transaction_txouts"
|
||||
SET "is_spent" = true
|
||||
WHERE "tx_hash" = $3 AND "tx_idx" = $4
|
||||
WHERE "tx_hash" = $3 AND "tx_idx" = $4 AND "is_spent" = false -- TODO: should throw an error if already spent
|
||||
RETURNING "pkscript"
|
||||
)
|
||||
INSERT INTO bitcoin_transaction_txins ("tx_hash","tx_idx","prevout_tx_hash","prevout_tx_idx","prevout_pkscript","scriptsig","witness","sequence")
|
||||
|
||||
@@ -93,7 +93,7 @@ const insertTransactionTxIn = `-- name: InsertTransactionTxIn :exec
|
||||
WITH update_txout AS (
|
||||
UPDATE "bitcoin_transaction_txouts"
|
||||
SET "is_spent" = true
|
||||
WHERE "tx_hash" = $3 AND "tx_idx" = $4
|
||||
WHERE "tx_hash" = $3 AND "tx_idx" = $4 AND "is_spent" = false -- TODO: should throw an error if already spent
|
||||
RETURNING "pkscript"
|
||||
)
|
||||
INSERT INTO bitcoin_transaction_txins ("tx_hash","tx_idx","prevout_tx_hash","prevout_tx_idx","prevout_pkscript","scriptsig","witness","sequence")
|
||||
|
||||
Reference in New Issue
Block a user