Bitcoin Forum
May 06, 2024, 09:24:07 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: unique identifier of a transaction  (Read 625 times)
killerstorm (OP)
Legendary
*
Offline Offline

Activity: 1022
Merit: 1015



View Profile
May 04, 2013, 03:53:59 PM
 #1

What can be an unique identifier of a transaction in view of BIP 30?

Apparently transactions with same hash can appear in different blocks.

What's about txhash+block_number?

Is it possible to have transactions with same hash in one block? BIP 30 doesn't say anything about it, but perhaps it is mentioned in some other rule.

If it is possible, then I guess the only identifier is a position in the blockchain, i.e. block hash + index of transaction within block.

Chromia: a better dapp platform
1715030647
Hero Member
*
Offline Offline

Posts: 1715030647

View Profile Personal Message (Offline)

Ignore
1715030647
Reply with quote  #2

1715030647
Report to moderator
1715030647
Hero Member
*
Offline Offline

Posts: 1715030647

View Profile Personal Message (Offline)

Ignore
1715030647
Reply with quote  #2

1715030647
Report to moderator
1715030647
Hero Member
*
Offline Offline

Posts: 1715030647

View Profile Personal Message (Offline)

Ignore
1715030647
Reply with quote  #2

1715030647
Report to moderator
The block chain is the main innovation of Bitcoin. It is the first distributed timestamping system.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715030647
Hero Member
*
Offline Offline

Posts: 1715030647

View Profile Personal Message (Offline)

Ignore
1715030647
Reply with quote  #2

1715030647
Report to moderator
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1024



View Profile
May 04, 2013, 04:11:21 PM
 #2

{blockhash,index} is unique.  As would be {blockhash,transactionhash} or even {transactionhash,blockheight}.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
Zeilap
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
May 04, 2013, 04:12:32 PM
 #3

Is it possible to have transactions with same hash in one block? BIP 30 doesn't say anything about it, but perhaps it is mentioned in some other rule.
It's really just the same rule. You can't have 2 live transactions (those with unspent outputs) with the same hash. See https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L2105.

If it is possible, then I guess the only identifier is a position in the blockchain, i.e. block hash + index of transaction within block.
Yes. Though you have to deal with the case where the transaction isn't in the blockchain separately.


Basically from the view of the reference client, there is no need for the identifier to be unique forever. The only need for looking up transactions is to get their unspent outputs. Once the outputs are spent, they never need to be looked up again, so the identifier can be reused.
killerstorm (OP)
Legendary
*
Offline Offline

Activity: 1022
Merit: 1015



View Profile
May 04, 2013, 04:30:37 PM
 #4

It's really just the same rule. You can't have 2 live transactions (those with unspent outputs) with the same hash.

No, it is a different rule.

BIP 30 essentially says that once all outputs are spent, it can appear again. But it is possible to create a transaction and spent all its outputs within one block, isn't it? Thus this transaction won't be live.


Hmm, this is interesting. It basically says that "This is caught by ConnectInputs()", but is it?

Perhaps it is meant that CheckInputs will detect transactions which try to spend same outputs, but in theory if transactions can reappear, it would be different outputs.

So it is possible that line 2105 is a rule on its own...


Basically from the view of the reference client, there is no need for the identifier to be unique forever. The only need for looking up transactions is to get their unspent outputs. Once the outputs are spent, they never need to be looked up again, so the identifier can be reused.

Yep. Unfortunately this doesn't work so well for colored coins...

Chromia: a better dapp platform
killerstorm (OP)
Legendary
*
Offline Offline

Activity: 1022
Merit: 1015



View Profile
May 04, 2013, 04:34:13 PM
 #5

{blockhash,index} is unique.  As would be {blockhash,transactionhash} or even {transactionhash,blockheight}.

Thanks. {transactionhash,blockheight} is what I wanted to use, but wasn't sure.

Chromia: a better dapp platform
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1024



View Profile
May 04, 2013, 04:53:00 PM
 #6

{blockhash,index} is unique.  As would be {blockhash,transactionhash} or even {transactionhash,blockheight}.

Thanks. {transactionhash,blockheight} is what I wanted to use, but wasn't sure.

I was going to add that {transactionhash,blockheight} needs special handling for reorgs, but really, all of these do anyway.

Note that other than the series of identical generate transactions, or spending one of the same, making a duplicate transactionhash is effectively impossible.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
TierNolan
Legendary
*
Offline Offline

Activity: 1232
Merit: 1083


View Profile
May 04, 2013, 04:56:12 PM
 #7

Thanks. {transactionhash,blockheight} is what I wanted to use, but wasn't sure.

This one can only be used once the transaction is added to a block.

Also, the odds of 2 transactions hashing to the same hash is extremely low.  The only reason it happened before is because you could create 2 coinbase transactions that were equal.

The new rule is that all coinbases transactions must be unique, since they include the chain height.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
Zeilap
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
May 04, 2013, 06:38:24 PM
 #8

But it is possible to create a transaction and spent all its outputs within one block, isn't it? Thus this transaction won't be live.
Heh, good point!


Hmm, this is interesting. It basically says that "This is caught by ConnectInputs()", but is it?
Short answer: No.
Longer answer: 'ConnectInputs()' doesn't exist anymore in the code. It never explicitly checked for duplicates because it was a check of a single transaction, so it couldn't know about the other transactions in the block. However, if the transactions are duplicate then updating the UTXO set will fail (presumably what it meant). If a true collision of different transactions this isn't true (as far as I can see).
The same is true now, the code has just moved to CheckInputs and UpdateCoins.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!