Bitcoin Forum
October 18, 2018, 06:35:45 AM *
News: Make sure you are not using versions of Bitcoin Core other than 0.17.0 [Torrent], 0.16.3, 0.15.2, or 0.14.3. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: is it too late to ask what is Segwit and how does it work?  (Read 656 times)
Leonard2016
Hero Member
*****
Offline Offline

Activity: 826
Merit: 520



View Profile WWW
July 03, 2017, 05:10:27 AM
 #1

i haven't been around much and i missed a lot and being not-techy (not zero knowledge but very little) is hard for me to understand what segwit is and how it is going to work for example in increasing the capacity.

i would like a simplified, in your own words explanation because i have read some stuff online but as i said being non-techy makes it hard for me to fully understand how it works.
for example this from bitcoincore.org
Quote
Block capacity/size increase

Since old nodes will only download the witness-stripped block, they only enforce the 1 MB block size limit rule on that data. New nodes, which understand the full block with witness data, are therefore free to replace this limit with a new one, allowing for larger block sizes. Segregated witness therefore takes advantage of this opportunity to raise the block size limit to nearly 4 MB, and adds a new cost limit to ensure blocks remain balanced in their resource use (this effectively results in an effective limit closer to 1.6 to 2 MB).

does this mean the new blocks are going to have new types of transaction which don't have any signature (scriptsig?) to make them technically bigger but still 1 MB?

and will this mean the new clients will hold blocks that are bigger? like 4 MB blocks?
1539844545
Hero Member
*
Offline Offline

Posts: 1539844545

View Profile Personal Message (Offline)

Ignore
1539844545
Reply with quote  #2

1539844545
Report to moderator
1539844545
Hero Member
*
Offline Offline

Posts: 1539844545

View Profile Personal Message (Offline)

Ignore
1539844545
Reply with quote  #2

1539844545
Report to moderator
1539844545
Hero Member
*
Offline Offline

Posts: 1539844545

View Profile Personal Message (Offline)

Ignore
1539844545
Reply with quote  #2

1539844545
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1539844545
Hero Member
*
Offline Offline

Posts: 1539844545

View Profile Personal Message (Offline)

Ignore
1539844545
Reply with quote  #2

1539844545
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 1554
Merit: 1703


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
July 03, 2017, 05:55:12 AM
 #2

Segwit creates a new type of output which moves the signature out of the scriptsig into a new field, the witness. The witness is not included in calculating the transaction id and it is also not counted as part of the 1 MB block size. This effectively reduces the size of a transaction (the part counted for the 1 MB) so that more transactions can be included. With witnesses, a block is now allowed to be 4 MB. Removing the witnesses from the transaction id calculation also makes transactions that spend from segwit outputs non-malleable.

Regarding the block size, technically segwit defines a new limit which supersedes the block size limit, a block weight limit. The block weight is defined as 3 * non-witness data + all data in a block. The maximum block weight is then 4 million weight units (basically bytes).

Leonard2016
Hero Member
*****
Offline Offline

Activity: 826
Merit: 520



View Profile WWW
July 03, 2017, 06:57:04 AM
 #3

now here is where i get confused.
can we use a real example. lets take this transaction that i got from blockchain.info
Quote
010000000118d68350c1dcda804cc1cf5d9137fea5ea90a2ec3ffee63c47881b42043197d301000 0006b483045022100b4004f6cc5fe81527b62b090a9c5cf0343e8d7e0092b749f797a0363cd1f8b9d022 03440e3f4dc6dc29f095b0a93eccf66b3fd9ac88713695bd71dc8ee61cc89776a012103424bf6a8 1b8b327631f044e11f18eb8fc665288739c5e72377614d3e7580721bffffffff0240933402000000001976a9140177884fc893f5264be7e424781f7574c7b3a6b788ac4 d3ed118000000001976a9141595049c14d3b94e24069e33480f9d182c518fea88ac00000000

i have made the scriptsig into bold. i am assuming this is what you call "the witness" correct?

Segwit creates a new type of output which moves the signature out of the scriptsig into a new field, the witness. it is also not counted as part of the 1 MB block size.
my confussion is about where is this "field" really located. is it still inside the transaction? if so then how will it look and how is it different?
and also by "not counted" do you mean it is not included in the 1 MB block if so how can you verify the transaction later on?

and if not, and it is included then i am more confused about the capacity increase:

Quote
Regarding the block size, technically segwit defines a new limit which supersedes the block size limit, a block weight limit. The block weight is defined as 3 * non-witness data + all data in a block. The maximum block weight is then 4 million weight units (basically bytes).

so how will the new blocks look like? will they take a larger space on the whole blockchain

sorry if the questions are too newbish. i recently started getting a better technical understanding of bitcoin and reading the bitcoin wiki, ... i can easily understand things but when it comes to segwit, everything becomes complicated probably because i have not found anything as well written as the wiki and also there is no examples helping me "visualize it" Smiley
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 1554
Merit: 1703


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
July 03, 2017, 07:46:20 AM
 #4

now here is where i get confused.
can we use a real example. lets take this transaction that i got from blockchain.info
Quote
010000000118d68350c1dcda804cc1cf5d9137fea5ea90a2ec3ffee63c47881b42043197d301000 0006b483045022100b4004f6cc5fe81527b62b090a9c5cf0343e8d7e0092b749f797a0363cd1f8b9d022 03440e3f4dc6dc29f095b0a93eccf66b3fd9ac88713695bd71dc8ee61cc89776a012103424bf6a8 1b8b327631f044e11f18eb8fc665288739c5e72377614d3e7580721bffffffff0240933402000000001976a9140177884fc893f5264be7e424781f7574c7b3a6b788ac4 d3ed118000000001976a9141595049c14d3b94e24069e33480f9d182c518fea88ac00000000

i have made the scriptsig into bold. i am assuming this is what you call "the witness" correct?
No. The scriptsig and witness are two separate things. The data that goes in the witness is the data that would go in the scriptsig if a witness output were a normal p2pkh or p2sh output. In this example transaction, if the output it is spending from was a pay-to-witness-pubkey-hash (p2wpkh), then the data that is in the scriptsig would be found in the witness. However, since the output is p2pkh, the data currently in the scriptsig would remain where it is even after segwit activates.

my confussion is about where is this "field" really located. is it still inside the transaction?
Yes. It is still part of the transaction. The transaction format has been extended for segwit.

if so then how will it look and how is it different?
Suppose that the example transaction you posted were spending from a p2wpkh output instead of a p2pkh output. The transaction would look like this:
Quote
0100000000010118d68350c1dcda804cc1cf5d9137fea5ea90a2ec3ffee63c47881b42043197d3010000006b00ffffffff0240933402000000001976a9140177884fc893f5264be7e424781f7574c7b3a6b788ac4 d3ed118000000001976a9141595049c14d3b94e24069e33480f9d182c518fea88ac02483045022100b4004f6cc5fe81527b62b090a9c5cf0343e8d7e0092b749f797a0363cd1f8b9d0 2203440e3f4dc6dc29f095b0a93eccf66b3fd9ac88713695bd71dc8ee61cc89776a012103424bf6 a81b8b327631f044e11f18eb8fc665288739c5e72377614d3e7580721b00000000
I have bolded the parts that have changed. The scriptsig is now empty, and what was in the scriptsig is now placed after the outputs. That field after the outputs is the witness. There is also a 0x0001 after the version number which lets us know that there is a witness field after the outputs.

and also by "not counted" do you mean it is not included in the 1 MB block if so how can you verify the transaction later on?
The data in the witness is not counted as part of the 1 MB block. The transaction is still verified as it normally would be since any node that can understand segwit will require that the transactions it receives are in the segwit serialization format. This means that it must receive the witnesses or the transaction will be considered invalid. The same goes with blocks; all transactions in a block that have witnesses must be in the segwit serialization format otherwise the block will be considered invalid.

so how will the new blocks look like?
They will look like they do now, but transactions that have witnesses will be in the segwit serialization format.

will they take a larger space on the whole blockchain
Yes. After segwit activates, the amount of space that a block can take up is 4 MB.

sorry if the questions are too newbish. i recently started getting a better technical understanding of bitcoin and reading the bitcoin wiki, ... i can easily understand things but when it comes to segwit, everything becomes complicated probably because i have not found anything as well written as the wiki and also there is no examples helping me "visualize it" Smiley
The BIPs contain all of this information with some examples too. Segwit is specified by BIPs 141, 143, and 144

Leonard2016
Hero Member
*****
Offline Offline

Activity: 826
Merit: 520



View Profile WWW
July 03, 2017, 09:48:27 AM
 #5

it never occured to me to check the BIPS! and they are exactly what i was looking for. thanks.

and thanks for patiently answering all my questions. it helped a lot.
wuala
Full Member
***
Offline Offline

Activity: 162
Merit: 100


Luk, soy tu padreeee


View Profile
August 26, 2017, 06:19:57 PM
 #6

Very interesting!!

Does it means that there will be one blockchain with blocks >1mb (sw) and blocks <1mb?

What does it means that SW transaction is seen by older nodes as a anyone-can-spend?

Leave the force be with you...
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 1554
Merit: 1703


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
August 26, 2017, 06:22:25 PM
 #7

Does it means that there will be one blockchain with blocks >1mb (sw) and blocks <1mb?
No. There is only one blockchain.

What does it means that SW transaction is seen by older nodes as a anyone-can-spend?
Yes. They are also non-standard, and given that the majority of nodes and miners are enforcing segwit, those transactions are not actually anyone-can-spend.

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!