Bitcoin Forum

Other => Beginners & Help => Topic started by: Unsaint32 on June 09, 2021, 01:31:39 AM



Title: BTC tx outputs. I am trying to understand
Post by: Unsaint32 on June 09, 2021, 01:31:39 AM
In one bitcoin transaction showing 2 outputs with different addresses, how do I know the wallet address of the recipient?  I guess I don't understand what the 2 addresses of the 2 outputs.  The 2 addresses are 2 public addresses of the wallet?  That doesn't make sense because the 2 addresses have different btc amounts. 


Title: Re: BTC tx outputs. I am trying to understand
Post by: DannyHamilton on June 09, 2021, 01:36:06 AM
In one bitcoin transaction showing 2 outputs with different addresses, how do I know the wallet address of the recipient?  I guess I don't understand what the 2 addresses of the 2 outputs.  The 2 addresses are 2 public addresses of the wallet?  That doesn't make sense because the 2 addresses have different btc amounts. 

If you sent the transaction, then you know which address you sent to.  The other address is an address in your own wallet that the change is sent back to.

If you did not send the transaction, then it is difficult to know for certain what each address is.  It's possible that thee sender sent a single transaction and paid 2 different people at the same time. It's possible that the sender sent bitcoins only to themselves moving bitcoins between wallets.  It's also possible that they sent a transaction to a single other person and that the change from the transaction was sent back to a new address in their own wallet.

Sometimes, depending on the amounts available, and the values of the outputs, it might be possible to make an educated guess as to what happened.  Sometimes that educated guess will be right, but it's always possible that the guess is wrong.


Title: Re: BTC tx outputs. I am trying to understand
Post by: pooya87 on June 09, 2021, 03:07:55 AM
Sometimes, depending on the amounts available, and the values of the outputs, it might be possible to make an educated guess as to what happened.
Considering almost all wallets are deterministic and most of them produce same address type, the address/script types involved in inputs and outputs also help with the guess.
If the input is coming from the same address type as the output that we guessed is the change while the other output(s) are of different type there chance of our guess being correct is higher.
P2WPKH ┌── P2PKH (different type, higher possibility of being someone else)
       └── P2WPKH (same type, higher possibility of being from same wallet)


Title: Re: BTC tx outputs. I am trying to understand
Post by: bitmover on June 09, 2021, 04:37:37 PM
In one bitcoin transaction showing 2 outputs with different addresses, how do I know the wallet address of the recipient?  I guess I don't understand what the 2 addresses of the 2 outputs.  The 2 addresses are 2 public addresses of the wallet?  That doesn't make sense because the 2 addresses have different btc amounts. 

You cannot really split coins.

Let's supposed you received 1 btc from an exchange in one transaction.

If you want to send 0.1 btc to a friend you cannot split your previous 1 btc.
You will sent 1 btc, and 0.1 will be send to your friend and 0.9 btc will come back to you as a chance  usually in another address.

This is the most common type of transaction  and this is probably the case you mentioned.

As DannyHamilton mentioned, you cannot really know for sure which is the change address , but you can try to guess. For example, usually change addresses have 8 fractional digits,  while the receiver is a round number.

For example , in the above case the receiver would be 0.1 and the change would be 0.8998373 (mining fees discounted)


Title: Re: BTC tx outputs. I am trying to understand
Post by: ARTURVHt on June 10, 2021, 06:22:58 AM
Simply put, a bitcoin transaction is the transfer of bitcoins from one address to another address. Different bitcoin addresses represent different bitcoin owners. Therefore, a bitcoin transaction means that the owner of bitcoin authorizes the transfer of bitcoin to a new address. The owner. Of course, the new Bitcoin owner can also authorize the transfer of Bitcoin to another owner, and so on, forming a chain of Bitcoin owners.


Title: Re: BTC tx outputs. I am trying to understand
Post by: NeuroticFish on June 10, 2021, 10:50:37 AM
In one bitcoin transaction showing 2 outputs with different addresses, how do I know the wallet address of the recipient?  I guess I don't understand what the 2 addresses of the 2 outputs.  The 2 addresses are 2 public addresses of the wallet?  That doesn't make sense because the 2 addresses have different btc amounts. 

If there are 2 outputs, then there are 2 recipients. As simple as that and basically that's all you know.
The fact that in reality there's a high chance that one of the recipients is the same or a different address in the sender's wallet, it's only a (rather small) detail.
If you know/expect that one of the addresses is the change address, then you can look for various other small details that can provide extra info:

* if one "recipient" address starts with the same character as the sender and the other doesn't, there's a good chance that the similar address is change address

* if one address received some pretty "round" amount (in BTC, or USD, or EUR, ..) then the other one may be the change address; also because many wallets don't do fee rounding, the recipient that got coins with more number of characters after the decimal point is probably the change wallet (because of the tx fee)


All these are assumptions based on common use, but most of the times they don't really give a 100% certainty.


Title: Re: BTC tx outputs. I am trying to understand
Post by: BlackFor3st on June 10, 2021, 12:00:53 PM
In one bitcoin transaction showing 2 outputs with different addresses, how do I know the wallet address of the recipient?  I guess I don't understand what the 2 addresses of the 2 outputs.  The 2 addresses are 2 public addresses of the wallet?  That doesn't make sense because the 2 addresses have different btc amounts. 

I'm not quite sure about this but I think I have the same questions before and found out the other address was my own wallet in other words that address was your exchange address. Just for example you have 1 Bitcoin and you only need to send 0.5 Bitcoins the 0.5 Bitcoin will send to your target address and the 0.5 will be sent back to you, I'm not just sure why it works like that.


Title: Re: BTC tx outputs. I am trying to understand
Post by: nc50lc on June 11, 2021, 04:02:07 AM
-snip-
I'm not quite sure about this but I think I have the same questions before and found out the other address was my own wallet in other words that address was your exchange address. Just for example you have 1 Bitcoin and you only need to send 0.5 Bitcoins the 0.5 Bitcoin will send to your target address and the 0.5 will be sent back to you, I'm not just sure why it works like that.
You almost got the name, it was "Change Address" not "Exchange Address"  ;)

It works like that because an "unspent transaction output" (UTXO) needs to be spent whole, a part of its value can't just be deducted.
Once a UTXO was spent, it can't be used again, that's why the excess amount should be a new UTXO (the change) or it will be considered as transaction fee.
Read this: https://en.bitcoin.it/wiki/Transaction#Output (https://en.bitcoin.it/wiki/Transaction#:~:text=Because%20each%20output,it%20to%20yourself))


Title: Re: BTC tx outputs. I am trying to understand
Post by: khaled0111 on June 11, 2021, 07:51:11 PM
...
Exactly! Bitcoin uses the UTXOs model. Each transaction consists of Inputs and Outputs and an Inputs is basically the output of a previous transaction.
The balance of an address is the sum of all its UTXOs (unspent transaction outputs) or simply the outputs it received from previous transactions but didn't spent them yet.
Now, if you want to create a transaction, you will use as much as needed of UTXOs to cover the spent amount and network fees. However you should know that an unspent transaction output has to be spent in full. So, if the value of the used inputs is bigger than the amount you want to spend (plus fees), the difference will be sent to one of your wallet addresses as an extra output.
Almost all bitcoin wallets do this automatically, though.


Title: Re: BTC tx outputs. I am trying to understand
Post by: Shymaa-Arafat on June 14, 2021, 08:21:03 AM
Quote
Sometimes, depending on the amounts available, and the values of the outputs, it might be possible to make an educated guess as to what happened.  Sometimes that educated guess will be right, but it's always possible that the guess is wrong.

Quote
P2WPKH ┌── P2PKH (different type, higher possibility of being someone else)
       └── P2WPKH (same type, higher possibility of being from same wallet)

What u both say here is almost what I mean we should consider when building the UTXOs Merkle Tree or whatever data structure used.
We should make an educated guess of how long this UTXO is going to stay & maybe also put it near others likely to be spent in the same transaction.
More here on previous results showing that UTXOs maybe divided to 2-3 groups according to their lifespan, we could add ur ideas here, and also guessing/identifying burned UTXOs as they will probably live forever in the system
https://mobile.twitter.com/ArafatShymaa/status/1403246321956438017
.
This should not be hard to do, only a few if statements added to the code (after accurate analysis of all TXs kinds not just a few like I did in coinbase, accumulating rewards, distributing rewards; and what u added here gratefully enriching the idea a lot).
.
-After these few "ifs" one could think of many ways the code could branch in..
  • -Two trees/forests one for long-living one for fast spending
  • -Weighted tree with less weights assigned to those staying for long (to give shorter paths for the fast spent ones)
....
[/list]
More thoughts in here
https://mobile.twitter.com/ArafatShymaa/status/1402465971147841537