Bitcoin Forum
June 20, 2024, 06:29:12 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Question about SegWit  (Read 3103 times)
JorgeStolfi (OP)
Hero Member
*****
Offline Offline

Activity: 910
Merit: 1003



View Profile
March 24, 2016, 02:19:45 PM
Merited by ABCbits (1)
 #1

Suppose Alice is running "new" (SegWit-capable) client software, and sends some bitcoin to Bob, who is running an "old" (SegWit-oblivious) client, with a SegWIt transaction T1.

I understand that Bob would still be able to spend that bitcoin with a non-SegWit transaction T2, by providing the proper signature; is that correct?

But would Bob know what signature he must provide, without Alice telling him?  Or will Bob's client believe that the output of T1 is "anyone can spend", and assume that T2 does not require a signature?

Academic interest in bitcoin only. Not owner, not trader, very skeptical of its longterm success.
jl777
Legendary
*
Offline Offline

Activity: 1176
Merit: 1132


View Profile WWW
March 24, 2016, 02:31:40 PM
 #2

Suppose Alice is running "new" (SegWit-capable) client software, and sends some bitcoin to Bob, who is running an "old" (SegWit-oblivious) client, with a SegWIt transaction T1.

I understand that Bob would still be able to spend that bitcoin with a non-SegWit transaction T2, by providing the proper signature; is that correct?

But would Bob know what signature he must provide, without Alice telling him?  Or will Bob's client believe that the output of T1 is "anyone can spend", and assume that T2 does not require a signature?
my understanding is that bob would have to send alice a segwit p2sh address, which he wouldnt have without running a segwit client. At least that is the assumption.

if bob creates a segwit p2sh address using his privkey, using some external mechanism, then his wallet wont be able to see it as it is a p2sh address it doesnt know about. and presumably if he tries to spend it by signing it, then I think if he signs it properly it will get confirmed by segwit miners. but bob wont be able to directly verify it, so would need to rely on third parties

http://www.digitalcatallaxy.com/report2015.html
100+ page annual report for SuperNET
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3430
Merit: 6720


Just writing some code


View Profile WWW
March 24, 2016, 02:32:44 PM
Last edit: March 24, 2016, 02:46:01 PM by knightdk
 #3

Suppose Alice is running "new" (SegWit-capable) client software, and sends some bitcoin to Bob, who is running an "old" (SegWit-oblivious) client, with a SegWIt transaction T1.

I understand that Bob would still be able to spend that bitcoin with a non-SegWit transaction T2, by providing the proper signature; is that correct?

But would Bob know what signature he must provide, without Alice telling him?  Or will Bob's client believe that the output of T1 is "anyone can spend", and assume that T2 does not require a signature?
It depends on how Alice sent the Bitcoin.

If Alice created a P2PKH or P2SH output (currently used) which Bob could spend from, then he would spend from that output normally as he does now. In this case, it doesn't matter if the inputs required segwit or not, they will be considered valid by Bob but his wallet won't even tell him about the transaction until it has confirmations.

If Alice sent him a P2WPKH output (new segwit output), AFAIK, Bob wouldn't even know about those transactions and that those outputs are even meant for him. If he did know about said outputs, he would probably spend them as anyonecanspend outputs and thus not require a signature. However the segwit nodes would reject such transactions and it would never be confirmed or even propagate very far.

If Alice sent him a P2WSH, P2WPKH-P2sh or P2WSH-P2SH (new outputs. The latter two are nested in p2sh outputs), Bob absolutely would not know that those outputs are meant for him.

Jimmy Wales
Member
**
Offline Offline

Activity: 140
Merit: 17


View Profile
March 24, 2016, 03:16:20 PM
 #4

Suppose Alice is running "new" (SegWit-capable) client software, and sends some bitcoin to Bob, who is running an "old" (SegWit-oblivious) client, with a SegWIt transaction T1.

I understand that Bob would still be able to spend that bitcoin with a non-SegWit transaction T2, by providing the proper signature; is that correct?

But would Bob know what signature he must provide, without Alice telling him?  Or will Bob's client believe that the output of T1 is "anyone can spend", and assume that T2 does not require a signature?
It depends on how Alice sent the Bitcoin.

If Alice created a P2PKH or P2SH output (currently used) which Bob could spend from, then he would spend from that output normally as he does now. In this case, it doesn't matter if the inputs required segwit or not, they will be considered valid by Bob but his wallet won't even tell him about the transaction until it has confirmations.

If Alice sent him a P2WPKH output (new segwit output), AFAIK, Bob wouldn't even know about those transactions and that those outputs are even meant for him. If he did know about said outputs, he would probably spend them as anyonecanspend outputs and thus not require a signature. However the segwit nodes would reject such transactions and it would never be confirmed or even propagate very far.

If Alice sent him a P2WSH, P2WPKH-P2sh or P2WSH-P2SH (new outputs. The latter two are nested in p2sh outputs), Bob absolutely would not know that those outputs are meant for him.
In short, is it possible that Bob receives a Tx created by Alice, which is included in a block (i.e. a confirmed Tx) and gives her a good/service in return, only to find out later that he can not spend the Tx outputs?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3430
Merit: 6720


Just writing some code


View Profile WWW
March 24, 2016, 03:23:46 PM
 #5

In short, is it possible that Bob receives a Tx created by Alice, which is included in a block (i.e. a confirmed Tx) and gives her a good/service in return, only to find out later that he can not spend the Tx outputs?
Probably not. His wallet is most likely unable to recognize that a P2WPKH output is meant for him because it does not have any OP codes to indicate what that data is and how to spend from such an output.

Jimmy Wales
Member
**
Offline Offline

Activity: 140
Merit: 17


View Profile
March 24, 2016, 03:45:41 PM
 #6

In short, is it possible that Bob receives a Tx created by Alice, which is included in a block (i.e. a confirmed Tx) and gives her a good/service in return, only to find out later that he can not spend the Tx outputs?
Probably not. His wallet is most likely unable to recognize that a P2WPKH output is meant for him because it does not have any OP codes to indicate what that data is and how to spend from such an output.
So, is the counter situation possible? Alice sends the Tx, but as Bob's wallet did not recognize it, she did not get the good/service for which she paid. In effect, Alice lost her coins. Is it possible?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3430
Merit: 6720


Just writing some code


View Profile WWW
March 24, 2016, 03:53:14 PM
 #7

In short, is it possible that Bob receives a Tx created by Alice, which is included in a block (i.e. a confirmed Tx) and gives her a good/service in return, only to find out later that he can not spend the Tx outputs?
Probably not. His wallet is most likely unable to recognize that a P2WPKH output is meant for him because it does not have any OP codes to indicate what that data is and how to spend from such an output.
So, is the counter situation possible? Alice sends the Tx, but as Bob's wallet did not recognize it, she did not get the good/service for which she paid. In effect, Alice lost her coins. Is it possible?
Yes but unlikely. This depends on the implementation. The current implementation is that entering an address will result in creating a normal P2PKH output which Bob could spend from. If there is an implementation that a P2WPKH output is created when an address is entered, then it is possible that Alice would, in effect, lose her coins if she used such an implementation.

Jimmy Wales
Member
**
Offline Offline

Activity: 140
Merit: 17


View Profile
March 24, 2016, 04:01:53 PM
 #8

In short, is it possible that Bob receives a Tx created by Alice, which is included in a block (i.e. a confirmed Tx) and gives her a good/service in return, only to find out later that he can not spend the Tx outputs?
Probably not. His wallet is most likely unable to recognize that a P2WPKH output is meant for him because it does not have any OP codes to indicate what that data is and how to spend from such an output.
So, is the counter situation possible? Alice sends the Tx, but as Bob's wallet did not recognize it, she did not get the good/service for which she paid. In effect, Alice lost her coins. Is it possible?
Yes but unlikely. This depends on the implementation. The current implementation is that entering an address will result in creating a normal P2PKH output which Bob could spend from. If there is an implementation that a P2WPKH output is created when an address is entered, then it is possible that Alice would, in effect, lose her coins if she used such an implementation.
But, how Alice's wallet would know whether Bob's wallet is SegWit compatible or not. Because, as I understand, depending on this Alice's wallet should create P2WPKH output or P2PKH output respectively.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3430
Merit: 6720


Just writing some code


View Profile WWW
March 24, 2016, 04:07:03 PM
 #9

But, how Alice's wallet would know whether Bob's wallet is SegWit compatible or not. Because, as I understand, depending on this Alice's wallet should create P2WPKH output or P2PKH output respectively.
Well if Alice somehow had a direct connection to Bob's wallet, her wallet would know because of the service bit indicating segwit. Otherwise, she would only know if Bob told her. However, the reference implementation creates by default a P2PKH output when an address is entered. This is to keep the backwards compatibility. I am assuming that there will be checkbox to allow the user to indicate if he wants to send it as a segwit output but that is not the current default.

fbueller
Sr. Member
****
Offline Offline

Activity: 412
Merit: 275


View Profile
March 24, 2016, 04:14:09 PM
 #10

I'm not sure this would ever be a problem. Look at the payment protocol; it basically tells a client what output scripts to pay to. (Addresses work in the same way, except the script-type is inferred from the version byte)

From Bobs perspective, there's only one output script he can accept, and he won't be convinced to accept anything else. Just like the amount isn't made up out of the air, neither is the script used to pay somebody. Bob won't hand over the goods until he gets paid.

Suppose the soft-fork activates on the rest of the network, and Bob is still using an old version of bitcoin core. He never created a seg-wit address before, so he certainly won't be looking for payment on one!

Also - as far as Alices ability to _guess_ output scripts (take the hash160 from his P2KH address, and craft a P2WPKH script) Bob would still regard this as non payment. This is because 'output scripts' are strictly the recipients business. How Bob chooses to protect his coins is his business - whether it's by multisig, or some other advanced script type - but it's something Alice cannot really question.

Bitwasp Developer.
gmaxwell
Moderator
Legendary
*
expert
Online Online

Activity: 4200
Merit: 8441



View Profile WWW
March 24, 2016, 05:19:44 PM
Merited by ABCbits (1)
 #11

Yes but unlikely. This depends on the implementation. The current implementation is that entering an address will result in creating a normal P2PKH output which Bob could spend from. If there is an implementation that a P2WPKH output is created when an address is entered, then it is possible that Alice would, in effect, lose her coins if she used such an implementation.
What you're saying is equivalent to "in theory there could exist some totally busted software that just make up random crap when alice punched in an address, thereby burning the coins"-- this is true, but it's unrelated to segwit. Smiley

The recipients address specifies the scriptPubkey that they must be paid-to in order to be paid.  If you don't pay to what they've specified, you haven't paid a party.  In the OP's example, Bob would have provided an ordinary address-- the same as he provides today, perhaps-- and the payment would work like normal.

How the txin scripts work and txout scripts work are completely orthogonal.  Someone can spend segwit coins and the receiver doesn't care, it doesn't change their operation; beyond the fact that their older client will see the payment as a non-standard transaction so their non-upgraded wallet will not display it until it confirms.
JorgeStolfi (OP)
Hero Member
*****
Offline Offline

Activity: 910
Merit: 1003



View Profile
March 24, 2016, 08:43:50 PM
 #12

But, how Alice's wallet would know whether Bob's wallet is SegWit compatible or not. Because, as I understand, depending on this Alice's wallet should create P2WPKH output or P2PKH output respectively.
Well if Alice somehow had a direct connection to Bob's wallet, her wallet would know because of the service bit indicating segwit. Otherwise, she would only know if Bob told her. However, the reference implementation creates by default a P2PKH output when an address is entered. This is to keep the backwards compatibility. I am assuming that there will be checkbox to allow the user to indicate if he wants to send it as a segwit output but that is not the current default.

OK, so now consider the reverse situation: Bob is running a new client, and Alice is running an old one.  If Bob wants Alice to send him coins, what should he tell her: "pay to this address" or "pay to this segwit script", or "pay to either"?

Or: suppose Alice wants to make a payment that can be collected by either Bob or Carol.  Bob is running an old client, and Carol a new one.  Bob tells Alice "pay me to this address",  Carol says "pay me to this segwit script".  What should Alice do?

Academic interest in bitcoin only. Not owner, not trader, very skeptical of its longterm success.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3430
Merit: 6720


Just writing some code


View Profile WWW
March 24, 2016, 08:52:17 PM
 #13

OK, so now consider the reverse situation: Bob is running a new client, and Alice is running an old one.  If Bob wants Alice to send him coins, what should he tell her: "pay to this address" or "pay to this segwit script", or "pay to either"?
He could give her a P2PKH address and he would receive the coins as he does now. Or he can give her a segwit script embedded in a P2SH address and he would receive the coins as he does now. He could tell her to make the output a specific script. It doesn't matter as an upgraded node is backwards compatible and can process the old and new output types.

Or: suppose Alice wants to make a payment that can be collected by either Bob or Carol.  Bob is running an old client, and Carol a new one.  Bob tells Alice "pay me to this address",  Carol says "pay me to this segwit script".  What should Alice do?
Er, is that possible now? Both parties receiving the payment would need to agree to the output type since they can both spend from the outputs. The obvious one is to simply pay to the address because that is one that is compatible with both clients.

Jet Cash
Legendary
*
Offline Offline

Activity: 2744
Merit: 2462


https://JetCash.com


View Profile WWW
March 29, 2016, 05:06:24 AM
 #14

As I understand it, Alice creates a "pay anybody record", and attaches a signature that says pay Bob. All miners will need to be on SegWit, so they will only allow Bob to claim the coins. The "Pay anyone" record will be part of Bob's blockchain, and will validate any future payments. Because he is running old software, he won't recognise the signature record,but that doesn't matter, as his payment has a valid source of funds. If he wants to track the payment in the future, he will have to use an archive node ( a node that keeps the signatures, and validates segwit traansactions. Miners will not include the signature record in the mined block, so the block can stay below 1Mb, this helps smaller miners who may not be able to compete with the high price installations of the large miners. The biggest threat to Bitcoin is centralisation, and a 2MB blocksize may force out smaller miners, and leave the network vulnerable to fee exploitation by a small group of miners. imho.

Offgrid campers allow you to enjoy life and preserve your health and wealth.
Save old Cars - my project to save old cars from scrapage schemes, and to reduce the sale of new cars.
My new Bitcoin transfer address is - bc1q9gtz8e40en6glgxwk4eujuau2fk5wxrprs6fys
JorgeStolfi (OP)
Hero Member
*****
Offline Offline

Activity: 910
Merit: 1003



View Profile
March 30, 2016, 08:52:06 AM
 #15

Miners will not include the signature record in the mined block, so the block can stay below 1Mb, this helps smaller miners who may not be able to compete with the high price installations of the large miners.

This is not correct, right?  Miners (and relay nodes running new software) will have to include the signatures in the extension part of the block and send the whole block out to other miners (and to relay nodes running new software).  The extension record can be omitted only when a miner or relay node sends a block to a simple client.  Right?

Quote
The biggest threat to Bitcoin is centralisation, and a 2MB blocksize may force out smaller miners, and leave the network vulnerable to fee exploitation by a small group of miners. imho.

Centralization has happened because of several factors that favor larger miners over smaller ones -- including economies of scale, access to locations with cheaper power and natural cooling, better prices for bulk purchases, in-house hardware and software development, and better support from local governments.  If it is true that larger blocks give an advantage to bigger miners, they could get those same advantages by artificially delaying the transmission of blocks to rivals.

Academic interest in bitcoin only. Not owner, not trader, very skeptical of its longterm success.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3430
Merit: 6720


Just writing some code


View Profile WWW
March 30, 2016, 11:44:43 AM
 #16

This is not correct, right?  Miners (and relay nodes running new software) will have to include the signatures in the extension part of the block and send the whole block out to other miners (and to relay nodes running new software).  The extension record can be omitted only when a miner or relay node sends a block to a simple client.  Right?
Yes, you are mostly correct. The witness data is sent to nodes that have the proper service bit set. When segwit activates, nearly all of the miners will have this bit set so they will be receiving all of the witness data. The data will be omitted if the node doesn't have that service bit.

Jet Cash
Legendary
*
Offline Offline

Activity: 2744
Merit: 2462


https://JetCash.com


View Profile WWW
March 30, 2016, 02:57:45 PM
 #17

This is not correct, right?  Miners (and relay nodes running new software) will have to include the signatures in the extension part of the block and send the whole block out to other miners (and to relay nodes running new software).  The extension record can be omitted only when a miner or relay node sends a block to a simple client.  Right?
Yes, you are mostly correct. The witness data is sent to nodes that have the proper service bit set. When segwit activates, nearly all of the miners will have this bit set so they will be receiving all of the witness data. The data will be omitted if the node doesn't have that service bit.

I understood that the miners would have to validate the signature "extension" to guard against attempts to hijack the payment. Because of this, all miners would have to support segwit. However, they don't include the signature data in the mined block ( if they did it would be even larger than current sizes). They don't need to re-transmit the signature data, and probably won't as the extra processing time could lead to their block being orphaned. The signature data is validated by archive nodes, and other miners of course, and if it is invalid, then the block will not be accepted. I think it is optional if a wallet holder wants to run a pruned node, a full node, or a full node with archiving.

Offgrid campers allow you to enjoy life and preserve your health and wealth.
Save old Cars - my project to save old cars from scrapage schemes, and to reduce the sale of new cars.
My new Bitcoin transfer address is - bc1q9gtz8e40en6glgxwk4eujuau2fk5wxrprs6fys
David Rabahy
Hero Member
*****
Offline Offline

Activity: 709
Merit: 503



View Profile
March 30, 2016, 03:23:57 PM
 #18

I run a full node (it is my pleasure to provide this service to the community; besides which it is apparently to my advantage to participate in order to help keep Bitcoin viable to help keep my Bitcoins valuable).

Which variant will be best for me to run?  Pruned seems less helpful.  Full seems good but full with archive seems best.

Should I ever hope to be paid for being a full node with archive?
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
March 30, 2016, 04:03:41 PM
 #19

Should I ever hope to be paid for being a full node with archive?
no.
there is no person in this universe who has reasons pay you just for holding a node
Jet Cash
Legendary
*
Offline Offline

Activity: 2744
Merit: 2462


https://JetCash.com


View Profile WWW
March 30, 2016, 04:05:23 PM
 #20

I hope to run an archiving node ( I hope that is the correct term). mainly because I believe that segwit will provide some interesting support for escrow services.

btw. don't forget that I am a recent Bitcoin recruit, so I hope my comments are correct. I think the concept is brilliant as it allows people to run previous versions of core without compromising their wallets. I think I read that there is a 50% fee refund if you are running a segwit node.

Offgrid campers allow you to enjoy life and preserve your health and wealth.
Save old Cars - my project to save old cars from scrapage schemes, and to reduce the sale of new cars.
My new Bitcoin transfer address is - bc1q9gtz8e40en6glgxwk4eujuau2fk5wxrprs6fys
Pages: [1] 2 »  All
  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!