Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for failed transactions due to double spends #10

Open
ssadler opened this issue Jun 3, 2020 · 0 comments
Open

Check for failed transactions due to double spends #10

ssadler opened this issue Jun 3, 2020 · 0 comments
Labels
bug Something isn't working RPC

Comments

@ssadler
Copy link
Owner

ssadler commented Jun 3, 2020

bitcoinSubmitTxSync :: Has BitcoinConfig r => Int -> SaplingTx -> Zeno r H.TxHash
bitcoinSubmitTxSync confirmations tx = do
txid <- queryBitcoin "sendrawtransaction" [tx]
fix $ \f -> do
threadDelay 5000000
rawtx <- queryBitcoin "getrawtransaction" (txid, 1::Int)
case rawtx .? "{confirmations}" of
Nothing -> f
Just (n::Int) -> if n < confirmations then f else pure txid

There's currently a possibility for the submit to return OK, but then a double spend to occur (accidentally or otherwise) and take out one of the inputs. getrawtransaction won't indicate that there's a problem in this case, so it'll loop forever. This should be made more robust, by repeatedly calling submitrawtransaction, or some other way, that would give indication in the case of a double spend.

@ssadler ssadler added bug Something isn't working RPC labels Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working RPC
Projects
None yet
Development

No branches or pull requests

1 participant