Skip to content

Check for failed transactions due to double spends #10

@ssadler

Description

@ssadler

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RPCbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions