Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Aleš Janda on May 11, 2016, 02:44:38 PM



Title: Where is witness part in SegWit transaction?
Post by: Aleš Janda on May 11, 2016, 02:44:38 PM
Hi,

I'm trying to understand how SegWit transaction looks like.

In article Segregated Witness, Part 1 (https://bitcoinmagazine.com/articles/segregated-witness-part-how-a-clever-hack-could-significantly-increase-bitcoin-s-potential-1450553618) on BitcoinMagazine.com is written

Quote
from the perspective of Bitcoin nodes that don't use Segregated Witness (lets call them “old nodes”), some newly created outputs might soon use a strange type of scriptPubKeys. Strange, because these scriptPubKeys can hardly be considered a lock at all. Commonly referred to as an “Anyone can spend,” these scriptPubKeys basically proclaim they don't require a signature. Additionally, they will include some meaningless text.
(embolden by me)

So I tried to send some segnet bitcoin from faucet (https://segwit.greenaddress.it/faucet/) to my address. The transaction (https://segnet.smartbit.com.au/tx/ea3bc375d80e99600fad4b5260c67f86c7b0dbc773b1e2b340c60951c6dce301) outputs look like

Code:
  "outputs": [
    {
...
      "script_pub_key": {
        "asm": "OP_DUP OP_HASH160 b94d3e2318aa7265f5c75be6275c5af35a3751bf OP_EQUALVERIFY OP_CHECKSIG",
...
      },
...
    },
    {
...
      "script_pub_key": {
        "asm": "OP_DUP OP_HASH160 b5255516286472ed5b15833da1d9ea97c8d3f05c OP_EQUALVERIFY OP_CHECKSIG",
...
      },
...
    }
  ],

This looks like standard transaction to me. When I pick random transaction from current blockchain, let's say https://blockchain.info/tx/a569b7a41c9a2567b4a4bad4ed59f5e846cc30d652b448ff6430018fe0bf3128, I see:

Code:
OP_DUP OP_HASH160 ed1fd913ec4f7f1b5699fc77ca9dc9604a840600 OP_EQUALVERIFY OP_CHECKSIG

on output, so the same format.

Also when I get transaction from segwit in hexadecimal and try to decode it in current Bitcoin version, it is the same (except the addresses because address version).

Please, can someone enlighten me what is different on SegWit? Where I can see the witness part? I'm definitely missing something… :)

Thanks a lot :)



Title: Re: Where is witness part in SegWit transaction?
Post by: achow101 on May 11, 2016, 03:32:31 PM
You need to spend from segwit outputs, which are not created by default. To do so, you need to create an address for segwit; there's an RPC command for it. Then spend from that address and you will see a segwit transaction.
You should also read the BIPs for segwit.


Title: Re: Where is witness part in SegWit transaction?
Post by: Aleš Janda on May 12, 2016, 08:30:05 AM
That is the thing! Thank you!

I created address by standard way, then in console
Code:
addwitnessaddress ADDRESS
creates new witness address from it. And transaction from has "txinwitness" part and so on.
Another good tool with examples is https://blockchainprogramming.azurewebsites.net/checktx

Thank you again.