Bitcoin Forum
May 21, 2024, 01:12:32 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Another segwit question. How is it stored?  (Read 95 times)
?QuestionMark? (OP)
Member
**
Offline Offline

Activity: 79
Merit: 28


View Profile
January 12, 2021, 08:58:26 PM
 #1

I know now about segwit that the witness data gets removed from the inputs and for an old node it looks like an everyone can spend output. So the old nodes receive only the <= 1MB block segwit and legacy transactions. It allowes old nodes to operate. And the new ones get the <= 3MB additional segwit data. So where is the witness data stored? Is it in a additional block or a just in a data set like a database?
A-Bolt
Legendary
*
Offline Offline

Activity: 2317
Merit: 2318


View Profile
January 12, 2021, 09:12:51 PM
 #2

So where is the witness data stored?

The witness data is stored in transaction.
From BIP141:
Code:
Legacy tx:
[nVersion][txins][txouts][nLockTime]

SegWit tx:
[nVersion][marker][flag][txins][txouts][witness][nLockTime]

pooya87
Legendary
*
Offline Offline

Activity: 3458
Merit: 10566



View Profile
January 13, 2021, 05:12:24 AM
 #3

the witness data gets removed from the inputs and for an old node it looks like an everyone can spend output.
It is not possible to remove witness from a transaction just as it is not possible to remove a signature script from a transaction. What you are referring to here is the process of dumbing down the transactions/blocks for old nodes that haven't yet updated to the new features added 4 years ago so that they can accept those blocks and don't fall behind.

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

Activity: 79
Merit: 28


View Profile
January 13, 2021, 12:05:34 PM
 #4

the witness data gets removed from the inputs and for an old node it looks like an everyone can spend output.
It is not possible to remove witness from a transaction just as it is not possible to remove a signature script from a transaction. What you are referring to here is the process of dumbing down the transactions/blocks for old nodes that haven't yet updated to the new features added 4 years ago so that they can accept those blocks and don't fall behind.

Just to be sure.
Theres an extra segwitwitness field in transactions but the scriptSig is empty. Old nodes don't get the segwitwitness in the tx, its dumped down. And the hashed transaction without the witness data is the txid (which prevents changing of sig and txid). Nodes with segwit have have a different hash of tx but the txid is the same?
pooya87
Legendary
*
Offline Offline

Activity: 3458
Merit: 10566



View Profile
January 14, 2021, 06:52:22 AM
 #5

Just to be sure.
Theres an extra segwitwitness field in transactions but the scriptSig is empty. Old nodes don't get the segwitwitness in the tx, its dumped down. And the hashed transaction without the witness data is the txid (which prevents changing of sig and txid). Nodes with segwit have have a different hash of tx but the txid is the same?
There is a new field called "witness" added to transactions that have at least witness and the signature script content depends on type of the output being spent. For native SegWit inputs version 0 it is empty, for nested SegWit inputs it has to be a special redeem script.
It is simplified for old nodes by removing the witness from transactions.
The transaction ID is calculated using the stripped down version (witness removed) both for backward compatibility and to mitigate some malleability issues.
The transaction ID/hash that is used in inputs is the stripped down hash. The "witness transaction ID/hash" is the hash of the entire transaction with its witnesses and is only used in merkle root computation for commitment in coinbase transaction.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
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!