Author

Topic: Alice Payment in Bob's Cafe (Read 233 times)

legendary
Activity: 2968
Merit: 3684
Join the world-leading crypto sportsbook NOW!
June 12, 2018, 03: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
legendary
Activity: 3122
Merit: 2178
Playgram - The Telegram Casino
June 12, 2018, 11:55:42 AM
#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
btj
member
Activity: 115
Merit: 16
June 12, 2018, 10:56:39 AM
#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/
sr. member
Activity: 742
Merit: 395
I am alive but in hibernation.
June 12, 2018, 10:44:49 AM
#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 .)

legendary
Activity: 3122
Merit: 2178
Playgram - The Telegram Casino
June 12, 2018, 09:49:34 AM
#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.
legendary
Activity: 2968
Merit: 3684
Join the world-leading crypto sportsbook NOW!
June 12, 2018, 08:21:01 AM
#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.
sr. member
Activity: 742
Merit: 395
I am alive but in hibernation.
June 12, 2018, 07:26:14 AM
#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.
Jump to: