0

Let's say if the transaction tx_1 has one confirmation. But the tx_1 is fraudulent. Can it be rolled back? Here I am storing the confirmed blocks and if my transaction is in the block-1 then the confirmation of tx_1 is 1 and whenever the blocks come after the block-1 the confirmation will keep on incrementing. But after one confirmation, if the tx_1 is fraudulent then how to stop that transaction?

2

You cannot undo a confirmed transaction trivially. That is one of the key benefits of a network like Bitcoin.

If your tx has only 1 confirmation, you might yet be able to drop it by mining two blocks on the parent of the block that contains tx_1. However, this requires you to have enough hashpower to be able to do so before someone extends the chain building on the block containing tx_1, which is non-trivial. Additionally, even if you succeed in this, there is still a chance that someone might mine on the block you dropped and turn that into the longer chain again.

Usually, blocks which have been confirmed 6 times are considered irreversible. Practically, unless you have access to a large amount of hashpower, even 1 confirmation is effectively irreversible on the bitcoin chain (although orphan blocks do occasionally happen)

  • Say I am tracking a specific bitcoin transaction 'TX_1'. A confirmed block had the transaction information after I decoded the block, and I updated my database as : {transaction: 'TX_1', 'confirmation': 1} now how do I increment the number of confirmation, assuming I am still listening to the network through ZMQ. Should I expect the same transaction 'TX_1' to be present in upcoming blocks? – merklexy May 17 '18 at 14:46
  • When you receive the next block, check the prevblock hash. If it matches the block with your tx, increment by one. For the n+2 block, check the prevblock hash against the n+1 block, and increment by 1. So on and so forth. As long as new blocks keep building upon a chain including the block with your tx, it keeps adding confirmations – Raghav Sood May 17 '18 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.