Bitcoin Forum
April 25, 2024, 05:00:17 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Alice Payment in Bob's Cafe  (Read 212 times)
r1s2g3 (OP)
Sr. Member
****
Offline Offline

Activity: 742
Merit: 395


I am alive but in hibernation.


View Profile
June 12, 2018, 12:26:14 PM
 #1

I am reading the book

I am little bit confused by this transaction.

https://blockchain.info/tx/0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2?show_adv=true

Book explain that Alice paid for coffee from a big Input and 2 output generated , 1 for payment and other for unspent transaction back to Alice.

My question is, Why Alice not had to pay mining fees that is coming back to Alice wallet?
or it is something like that if you create input from large value, then it is sending one output and make sure update the Input as a part of single transaction to reflect balance correctly.

I am alive
1714064417
Hero Member
*
Offline Offline

Posts: 1714064417

View Profile Personal Message (Offline)

Ignore
1714064417
Reply with quote  #2

1714064417
Report to moderator
1714064417
Hero Member
*
Offline Offline

Posts: 1714064417

View Profile Personal Message (Offline)

Ignore
1714064417
Reply with quote  #2

1714064417
Report to moderator
1714064417
Hero Member
*
Offline Offline

Posts: 1714064417

View Profile Personal Message (Offline)

Ignore
1714064417
Reply with quote  #2

1714064417
Report to moderator
"This isn't the kind of software where we can leave so many unresolved bugs that we need a tracker for them." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
buwaytress
Legendary
*
Offline Offline

Activity: 2786
Merit: 3437


Join the world-leading crypto sportsbook NOW!


View Profile
June 12, 2018, 01:21:01 PM
 #2

Alice only made one transaction, so she paid the fees for that transaction... Effectively she pays for the work the miner needed to verify it and for the amount of information it took up.

What Alice got back was change. Think of paying a 2 dollar coffee with a 10 dollar note. You won't get charged to receive 8 dollars in change back.

██
██
██
██
██
██
██
██
██
██
██
██
██
... LIVECASINO.io    Play Live Games with up to 20% cashback!...██
██
██
██
██
██
██
██
██
██
██
██
██
HeRetiK
Legendary
*
Online Online

Activity: 2912
Merit: 2080


Cashback 15%


View Profile
June 12, 2018, 02:49:34 PM
 #3

Transactions can have both multiple inputs (think of a wallet with multiple addresses with only a small balance each) and multiple outputs (as in your example: money paid to the merchant and a change amount back to a new address). The fee you have to pay accounts for the whole transaction size (ie. in data).

Transactions with many inputs / outputs are larger (in terms of kb) than transactions with only few inputs / outputs -- this makes the first more expensive than the latter, in other words the amount of data required for Alice's change transaction is already accounted for. If Alice would not require a change transaction because she has close to the exact amount, she could, in theory, save on transaction fees, because a transaction with 1 input and 1 output is smaller than a transaction with 1 input and 2 outputs.

It is also worth noting that transaction fees are not an explicit part of the transaction, but rather the difference between inputs and outputs. So to illustrate using buwaytress example: Think of paying a 4.50 dollar coffee (because starbucks) with a 10 dollar note. You only ask for 5 dollar back so you leave 50 cent as a tip. And it's still just a single transaction.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
r1s2g3 (OP)
Sr. Member
****
Offline Offline

Activity: 742
Merit: 395


I am alive but in hibernation.


View Profile
June 12, 2018, 03:44:49 PM
 #4

Transactions with many inputs / outputs are larger (in terms of kb) than transactions with only few inputs / outputs -- this makes the first more expensive than the latter, in other words the amount of data required for Alice's change transaction is already accounted for. If Alice would not require a change transaction because she has close to the exact amount, she could, in theory, save on transaction fees, because a transaction with 1 input and 1 output is smaller than a transaction with 1 input and 2 outputs.

It is also worth noting that transaction fees are not an explicit part of the transaction, but rather the difference between inputs and outputs. So to illustrate using buwaytress example: Think of paying a 4.50 dollar coffee (because starbucks) with a 10 dollar note. You only ask for 5 dollar back so you leave 50 cent as a tip. And it's still just a single transaction.

Thanks for explaining , Now everything  is clear , Alice is paying transaction fees for 1 input and 2 output (generating more bytes in transaction) that will be definitely more if Alice transactions contains only 1 input and 1 output.

Now it become tricky that how we pay the merchant , Alice can do 2 small transaction to make up the sum for the Merchant but Merchant might not be happy as Merchant will get 2 Input and merchant will incur double transactions fess while sending out (so profit decreased .)


I am alive
btj
Member
**
Offline Offline

Activity: 115
Merit: 16


View Profile
June 12, 2018, 03:56:39 PM
 #5


Thanks for explaining , Now everything  is clear , Alice is paying transaction fees for 1 input and 2 output (generating more bytes in transaction) that will be definitely more if Alice transactions contains only 1 input and 1 output.

Now it become tricky that how we pay the merchant , Alice can do 2 small transaction to make up the sum for the Merchant but Merchant might not be happy as Merchant will get 2 Input and merchant will incur double transactions fess while sending out (so profit decreased .)



Here how the transaction fees is calculated:

Quote
Size of transaction = Number inputs * (Input Size) + Number of outputs * (Output Size) + 10 Bytes extra fixed fee required for the framework of the transaction

How to get the P2PKH input size ?

Quote
PREVOUT  + SCRIPTSIG + sequence = 32 + 4 + 1 + 1 + (71 or 72) + 1 + 33 (Compressed) + 4 = 147 or 148

Quote
PREVOUT: hash (32 bytes)
         index (4 bytes)
SCRIPTSIG: length (1 byte)
           CONTENTS: push opcode (1 byte)
                     signature (71 or 72 bytes)
                     push opcode (1 byte)
                     pubkey (33 bytes for compressed, 65 for uncompressed)
sequence (4 bytes)
Source: https://bitcoin.stackexchange.com/questions/48279/how-big-is-the-input-of-a-p2pkh-transaction

Quote
    Legacy input size: 148 bytes (compressed)

    Legacy output size: 34 bytes (compressed)

    Segwit input size: 104 bytes
    Segwit output size: 32 bytes

Outputs for P2PKH and P2SH are both the same size: 34 bytes

So let's take an example and calculate the size:
https://blockchain.info/tx/7e46a5ea9d9c19cd4d0c3d0a287419d7c1ae13049ac7ab8860b6ee0cec4ead17

We have 1 input
There 2 Output

Quote
So the transaction size ~= 13 * 148 + 2 * 34 + 10 ~= 226 Bytes

Check this link, you will learn more about it:
https://blog.rmcsoft.com/how-to-calculate-bitcoin-transaction-fee/
HeRetiK
Legendary
*
Online Online

Activity: 2912
Merit: 2080


Cashback 15%


View Profile
June 12, 2018, 04:55:42 PM
 #6

[...]

Now it become tricky that how we pay the merchant , Alice can do 2 small transaction to make up the sum for the Merchant but Merchant might not be happy as Merchant will get 2 Input and merchant will incur double transactions fess while sending out (so profit decreased .)

Not quite -- when Alice pays using tons of inputs the coins the merchant receives are consolidated into a single output. That means while Alice has to pay serious transaction fees, the merchant only needs to pay for a single input, ie. the consolidated single output from Alice's coins.

However, say Alice wants to troll the merchant with the scenario you had in mind. Then she would send him the owed coins not using only a single transaction, but multiple ones -- eg. instead of paying 0.5 BTC in bulk she manually sends 10 x 0.05 BTC. Even if the merchant receives all these transactions on the same address, you now have the situation of the merchant having to pay an increased transaction fee when moving their coins: The merchant now has multiple inputs (ie. 10 x 0.05 BTC) that they have to consolidate into a single output, just as Alice in the scenario above.

It is worth noting that in the future Schnorr signatures [1] may help with reducing the transaction size increase caused by multiple inputs.

[1] https://medium.com/@SDWouters/why-schnorr-signatures-will-help-solve-2-of-bitcoins-biggest-problems-today-9b7718e7861c

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
buwaytress
Legendary
*
Offline Offline

Activity: 2786
Merit: 3437


Join the world-leading crypto sportsbook NOW!


View Profile
June 12, 2018, 08:48:27 PM
 #7

Nice point there, HeRetik! Worth noting that merchants would rarely allow themselves to be exposed to trolls like Alice so would only accept a single transaction. This is also why most sites ask for min deposit amounts, to avoid collecting dust from trolls. In fact, most sellers only assign 1 address to collect payment and expect only a single tx to fulfil conditions.

Lightning Network would also help alleviate dust concerns. Alice could send everything in single satoshi payments over a channel and merchant might appreciate the silly display of exuberance with a chuckle Wink

██
██
██
██
██
██
██
██
██
██
██
██
██
... LIVECASINO.io    Play Live Games with up to 20% cashback!...██
██
██
██
██
██
██
██
██
██
██
██
██
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!