Bitcoin Forum
April 26, 2024, 01:25:49 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Segwit Questions  (Read 398 times)
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 05, 2020, 08:37:04 AM
Merited by ABCbits (2)
 #1

The below short article explains how Seqwit works.

https://medium.com/@BlockTalkChain/how-does-non-segwit-legacy-node-verify-segwit-transaction-c3bc0872842b

Quote
When running a verification on transaction like this, a SegWit miner or node knows where to find the signature data for verification

Does this mean a SeqWit miner will transmit a successfully mined Bitcoin Block that is > 1 MB.   The data beyond the 1 MB point in the Block stores the scriptSig and scriptPubKey?

A non-SegWit (Legacy) Miner will just store the traditional 1 MB block?  What marks the end of a traditional Bitcoin Block, marking the beginning of the witness data in the extended Segwit Block?

Thank you
1714137949
Hero Member
*
Offline Offline

Posts: 1714137949

View Profile Personal Message (Offline)

Ignore
1714137949
Reply with quote  #2

1714137949
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 05, 2020, 09:08:27 AM
 #2

On this site it states that the Bitcoin Block has the field Blocksize which demarks the end of the block.  So the Witness data is stored after this point on Segwit Nodes?

https://en.bitcoin.it/wiki/Block
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
August 05, 2020, 10:58:47 AM
Last edit: August 05, 2020, 11:10:24 AM by Coding Enthusiast
Merited by Welsh (3), ABCbits (1), Heisenberg_Hunter (1)
 #3

AFAIK the witness data is stored at the end of the block.

Witness is not something separate to be stored separately, it is a part of each transaction like the transaction's version, locktime, outpoint and so on. Each witness of each transaction is stored inside that transaction as a new field right after the last txout and right before the locktime.

On this site it states that the Bitcoin Block has the field Blocksize which demarks the end of the block.  So the Witness data is stored after this point on Segwit Nodes?

https://en.bitcoin.it/wiki/Block
That is a mistake, the is NOT block structure. That looks like a half cut off P2P Block message.
The message starts with a magic (byte[] { 0xf9, 0xbe, 0xb4, 0xd9 }), then message name/type (block\0\0\0\0\0\0\0), message data length, checksum, message data.
in this case the "message data" part is a block which has the following structure:
block header, number of transactions, array of transactions

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 06, 2020, 04:55:39 AM
 #4

Quote
In fact, SegWit node will strip the witness data before sending the block to legagy node.

Interesting, so a SeqWit node sends out two versions of the Mined Block?  The stripped version for Legacy Nodes and the Extended Witness Data Block for Segwit nodes?

Thanks
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
August 06, 2020, 10:40:06 AM
Last edit: August 06, 2020, 11:10:49 AM by gmaxwell
Merited by ABCbits (1)
 #5

Quote
In fact, SegWit node will strip the witness data before sending the block to legagy node.

Interesting, so a SeqWit node sends out two versions of the Mined Block?  The stripped version for Legacy Nodes and the Extended Witness Data Block for Segwit nodes?

Thanks

If it's connected to an old non-segwit peer it'll send that peer a stripped block. All blocks it receives are the complete blocks, and of course any it sends to modern nodes are complete too.

There aren't that many pre-segwit nodes on the network anymore since segwit has been out for something very close to four years now. E.g. my node at home has 45 peers right now and every one of them is node_witness.

Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 07, 2020, 07:30:42 AM
 #6

Thanks for everyone's responses.
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 11, 2020, 11:49:19 AM
 #7

I am still confused about something.

The Segwit Node makes scriptSig: OP_TRUE,  and scriptPubKey: Empty and places this in the Block. 

However, how does scriptSig: OP_TRUE unlock the original Pre-Segwit input UTXO A with scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d OP_EQUALVERIFY OP_CHECKSIG on the Non-Segwit node? 

The Non-Segwit node should reject scriptSig: OP_TRUE as the unlocking Script for UTXO A and not include this block.

I can see how the Non-Segwit node would accept scriptSig: OP_TRUE if UTXO A scriptPubKey: Empty but when Segwit was initially implemented none of the UTXO's contained scriptPubKey: Empty

So how was this backwards compatible when Segwit first kicked off?

Thanks
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
August 11, 2020, 02:12:39 PM
 #8

However, how does scriptSig: OP_TRUE unlock the original Pre-Segwit input UTXO A with scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d OP_EQUALVERIFY OP_CHECKSIG on the Non-Segwit node? 
It doesn't. Segwit style signing is only used for segwit style outputs.  Old style outputs are spent using the old means.
pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10504



View Profile
August 12, 2020, 03:07:40 AM
 #9

The Segwit Node makes scriptSig: OP_TRUE,  and scriptPubKey: Empty and places this in the Block.

So how was this backwards compatible when Segwit first kicked off?

think of SegWit as some additional steps and a new field added to transactions that old nodes don't see but new nodes see and know what those steps are.

to an old node, everything that happened before is still happening the same exact way (eg. OP_DUP, OP_HASH160 <push20> OP_EQUALVERIFY OP_CHECKSIG is the same as ever). any SegWit output is also a very simple script to them (OP_number <push_some_data>) and is evaluating the same way as before too. if you know how scripts work you know that after executing this script the stack will contain 2 items (a number and some data that is never all zeros) and the top stack item is not-false so it evaluates to true.

however when the new nodes see (OP_number <push_some_data>) they know they have to take additional steps. for example if OP_number is OP_0 then they expect the push to be 20 or 32 bytes, the signature to be empty and they expect 2 for the first length or at least one for the second length in that new field called the "witness" as stack items which they use to evaluate the script.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 12, 2020, 05:28:55 AM
 #10

Quote
It doesn't. Segwit style signing is only used for segwit style outputs.  Old style outputs are spent using the old means.

So that means the Segwit process started with the Miners that updated their Software.  The Segwit Miners made scriptPubKey: Empty in the coinbase transaction.

So scriptPubKey: Empty indicates that this is a Segwit UTXO.   A non-Segwit node will ignore all UTXO where scriptPubKey: Empty but a Segwit node will know which Bitcoin Address this UTXO belongs to.   When a Segwit node builds a new transaction with a Segwit UTXO it will construct it with Standard Scripts containing (Digital Signature + PubKey and a Locking Script).  However, when a Segwit Miner places the new Segwit transaction into the block they will put  scriptSig: OP_TRUE scriptPubKey: Empty to continue the Segwit UTXO chain.

When a Segwit Transaction is seen by a Non-Segwit node it rejects it because the Locking Script for the input UTXO is a non-standard script but a Non-Segwit node accepts blocks with scriptSig: OP_TRUE scriptPubKey: Empty which enables Segwit to work.

Is my understanding correct now?

Thank you
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 12, 2020, 05:40:06 AM
 #11

Quote
SegWit output is also a very simple script to them (OP_number <push_some_data>)

I am not sure where OP_number <push_some_data> fits in since it's not mentioned in the article I referenced at the start of my thread.

https://medium.com/@BlockTalkChain/how-does-non-segwit-legacy-node-verify-segwit-transaction-c3bc0872842b

But I think this may be used to acquire the actual Witness data that is stored beyond the regular limits of a Non-Segwit Block?
pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10504



View Profile
August 12, 2020, 06:37:13 AM
Merited by ABCbits (3)
 #12

I am not sure where OP_number <push_some_data> fits in since it's not mentioned in the article I referenced at the start of my thread.
OP_number is any OP code that is followed by a number is is simply pushing an integer to the stack. anything except negative one is used in SegWit outputs that is OP_0, OP_1, OP_2,.... OP_16.

here are two examples:
Code:
0014ecd2c537b2222dc367110450e2526beef3f2d110
OP_0 <ecd2c537b2222dc367110450e2526beef3f2d110>
Code:
52207713dd0580bec75aa5e74f53b9f34657c4af0cd9bcedbae7cfd062afb3d16b15
OP_2 <7713dd0580bec75aa5e74f53b9f34657c4af0cd9bcedbae7cfd062afb3d16b15>
currently only version 0 (OP_0) is defined.

Quote
But I think this may be used to acquire the actual Witness data that is stored beyond the regular limits of a Non-Segwit Block?
if we see this pubkey script is being spent then it signals the mandatory existence of witness in that transaction and some other rules such as signature script being empty.

The Segwit Miners made scriptPubKey: Empty in the coinbase transaction.
no, an empty pubkey script means nothing special. a SegWit node verifies all transactions including those that have witnesses and constructs the block and its coinbase transaction as before with 2 additional steps:
- add a single witness reserved value in coinbase witness
- add the witness commitment as a new pubkey script using OP_Return
ax explained in BIP-141

Quote
So scriptPubKey: Empty indicates that this is a Segwit UTXO.
no, a pubkey script that is in the way i explained above (OP_0 to OP_16 followed by a single push of between 2 to 40 bytes) is indicating a SegWit UTXO.\

this is similar to P2SH softfork. a pubkey script that is OP_HASH160 <20 bytes> OP_EQUAL demands extra steps that only new nodes understand and old nodes (before P2SH upgrade) can not verify.

Quote
A non-Segwit node will ignore all UTXO where scriptPubKey: Empty but a Segwit node will know which Bitcoin Address this UTXO belongs to.
no. nodes don't ignore anything and they must know which UTXO they belong to. keep in mind UTXO is not fetched by the script but by using the hash and index inside tx_in outpoint. the old nodes don't see the witness.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 12, 2020, 07:16:41 AM
 #13

Thanks for your response pooya87. 

What you are describing is not in complete alignment with the article I referenced.  Is the article a simplified version of what you are now explaining to me?

Thanks
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
August 12, 2020, 01:16:24 PM
Merited by pooya87 (1)
 #14

The short answer is yes, that article is a very (over) simplified and somewhat inaccurate explanation of SegWit... Undecided

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 13, 2020, 05:17:34 AM
 #15

The short answer is yes, that article is a very (over) simplified and somewhat inaccurate explanation of SegWit... Undecided

Good to know.  I assumed the referenced article did a decent job at explaining Segwit but apparently not.

Thanks for all the responses.  I am learning a lot from this forum.
Picard78 (OP)
Member
**
Offline Offline

Activity: 68
Merit: 23


View Profile
August 23, 2020, 06:21:46 AM
Last edit: August 23, 2020, 07:32:51 AM by Picard78
 #16

I have been looking at the latest confirmed Block Sizes today and most are under 1.5 MB.  I read that Segwit should provide savings of around 60-65% which should put the Block Size well above 2 MB.  So is it safe to say that the large majority of nodes are presently Seqwit nodes but there are still many Bitcoin Addresses that haven't upgraded to bc1?
ranochigo
Legendary
*
Offline Offline

Activity: 2954
Merit: 4165


View Profile
August 23, 2020, 06:46:08 AM
 #17

I have been looking at the latest confirmed Block Sizes today and most are under 1.5 MB.  I read that Segwit should provide savings of around 60-65% which should put the Block Size well above 2 MB. 
That's in theory. In practice, the best real world estimates still puts it below 2MB.
So it it safe to say that the large majority of nodes are presently Seqwit nodes but there are still many Bitcoin Addresses that haven't upgraded to bc1?
Segwit was activated for quite a long time and that Bitcoin Core has adopted segwit for quite a few revisions already. Majority of the nodes (based on bitnodes) is running on a segwit-compatible version.

It's not quite the right phrasing to upgrade Bitcoin addresses but it's more accurate to say converted. The main culprit is some of the services that refuses to adopt segwit address types. You also cannot tell a normal P2SH from a P2WSH transaction until it is spent at least once. I would say the statistics might be slightly skewed.

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

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

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

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

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

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











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











▄▄▄▄█
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!