Bitcoin Forum
September 24, 2018, 01:04:20 AM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: What happens when non-Segwit transactions are sent to Segwit nodes?  (Read 1001 times)
victoriobn
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
August 28, 2017, 10:57:41 PM
 #1

Hi everyone,

I understand what happens when Segwit nodes broadcasts new transactions to non-Segwit (or legacy) nodes. Putting in a simple way, transactions are transmitted without witness data and is still considered valid to the legacy. Then, legacy validates it, adds to the mempool and broadcasts to all connected nodes.

What I don't understand is the opposite way. What happens when a legacy (or non-Segwit) node sends transactions to Segwit nodes? Segwit nodes understand this "old fashion" transaction? Or it needs to transform it into a Segwit transaction by "rearranging" the witness data before validating it and adding to the mempool?

The same questioning goes to the block when a non-Segwit node broadcasts it to a Segwit node.

Thanks in advance Wink



1537751060
Hero Member
*
Offline Offline

Posts: 1537751060

View Profile Personal Message (Offline)

Ignore
1537751060
Reply with quote  #2

1537751060
Report to moderator
1537751060
Hero Member
*
Offline Offline

Posts: 1537751060

View Profile Personal Message (Offline)

Ignore
1537751060
Reply with quote  #2

1537751060
Report to moderator
1537751060
Hero Member
*
Offline Offline

Posts: 1537751060

View Profile Personal Message (Offline)

Ignore
1537751060
Reply with quote  #2

1537751060
Report to moderator
Make a difference with your Ether.
Donate Ether for the greater good.
SPRING.WETRUST.IO
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1654


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
August 28, 2017, 11:15:54 PM
 #2

Segwit nodes still understand legacy transactions. Segwit does not change this at all whatsoever. Furthermore, for transactions that do not have witnesses, the witness format of that transaction is the legacy transaction format. So nothing happens; everything works as normal.

victoriobn
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
August 29, 2017, 12:50:04 AM
 #3

@achow101 thanks a lot man!

So, both types of transactions can coexists in Segwit nodes mempool at the same time? They are then broadcasted to other nodes as is?

Just one more question: once a Segwit node receives a non-Segwit transaction, are there instructions like "if Segwit do this || if non-Segwit do that" in order to put it in the mempool?

The same reasoning apply to blocks sent from non-Segwit to Segwit nodes? I ask cause, when sending from a Segwit node, there are instructions that orientate the "block type" to be broadcasted accordingly to the destiny (Segwit or Legacy), as shown bellow:

Code:
if (inv.type == MSG_BLOCK)
     connman.PushMessageWithFlag(pfrom, SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::BLOCK, block);
else if (inv.type == MSG_WITNESS_BLOCK)
     connman.PushMessage(pfrom, NetMsgType::BLOCK, block);

Thanks again Smiley
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1654


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
August 29, 2017, 01:06:43 AM
 #4

So, both types of transactions can coexists in Segwit nodes mempool at the same time? They are then broadcasted to other nodes as is?
Yes.

Just one more question: once a Segwit node receives a non-Segwit transaction, are there instructions like "if Segwit do this || if non-Segwit do that" in order to put it in the mempool?
No. The verification processes are basically the same, but for segwit transactions, there are a few extra steps prior to main validation to check that a transaction that spends from witness transactions has a txwitness field and the marker and flag bytes.

The same reasoning apply to blocks sent from non-Segwit to Segwit nodes? I ask cause, when sending from a Segwit node, there are instructions that orientate the "block type" to be broadcasted accordingly to the destiny (Segwit or Legacy), as shown bellow:

Code:
if (inv.type == MSG_BLOCK)
     connman.PushMessageWithFlag(pfrom, SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::BLOCK, block);
else if (inv.type == MSG_WITNESS_BLOCK)
     connman.PushMessage(pfrom, NetMsgType::BLOCK, block);

Thanks again Smiley
No. The block format is not different with segwit. The only thing different is that any transactions spending segwit outputs must be in the witness extended format (the format with marker and flag bytes and txwitness field). But the block format itself is not different.

polyhedron
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
August 29, 2017, 01:19:41 AM
 #5

No. The block format is not different with segwit. The only thing different is that any transactions spending segwit outputs must be in the witness extended format (the format with marker and flag bytes and txwitness field). But the block format itself is not different.
Can I understand it as, whether a transaction applies to SegWit or not, depends on the sender address, not receptor address nor the way it choose to send?
victoriobn
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
August 31, 2017, 03:00:53 PM
 #6

@achow101,

Currently I see that only about 5% of all tx are segwit tx.

So what happens to the block tx structure?

I mean, 95% non-segwit tx will be in the merkle tree alongside with the 5% segwit tx, right?

Also, only witness data from the 5% of segwit tx will be in the tiny coinbase witness merkle tree? How would it look like?

Thanks again man o/
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1654


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
August 31, 2017, 03:08:45 PM
 #7

Can I understand it as, whether a transaction applies to SegWit or not, depends on the sender address, not receptor address nor the way it choose to send?
Yes.

@achow101,

Currently I see that only about 5% of all tx are segwit tx.

So what happens to the block tx structure?

I mean, 95% non-segwit tx will be in the merkle tree alongside with the 5% segwit tx, right?

Also, only witness data from the 5% of segwit tx will be in the tiny coinbase witness merkle tree? How would it look like?

Thanks again man o/
It doesn't look any different. The witness merkle root also contains the hashes of all of the non-witness transactions too since that is actually the hash of the entire transaction, not just the txid.

victoriobn
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
August 31, 2017, 04:25:39 PM
 #8

Got it @achow101

Thanks Wink
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!