< GitHub115>
[bitcoin] sipa opened pull request #9039: Various serialization simplifcations and optimizations (master...simpleserial) https://github.com/bitcoin/bitcoin/pull/9039
< Bi>
Guys, if I have a block with only the coinbase tx and one segwit tx. It takes sha256->sha256 on 64 bytes of data to calculate the witness' merkle - right?
< Bi>
And the first 32 bytes are zero?
< Bi>
While the other 32 bytes is sha256->sha256 of the raw segwit transaction?
< Bi>
It seems very simple, but I must be doing something wrong, beacuse my merkle roots dont match the expected values
< Bi>
Can someone please help me?
< Bi>
Or maybe you could at leat tell me what is wtxid of this transaction: 01000000000101f15a2db447e8316e9f20073ab8bdeac53df1a53d415fbd41e73929699b889e7a0000000017160014fb459699ce9ca78de6d0790121dfb215883acb64ffffffff0100111024010000001976a914fb459699ce9ca78de6d0790121dfb215883acb6488ac02483045022100c5feadba5fbcc28afb940c7ee664bba81830f19a5407ae49cf75f565534b149702200a7c2b6b1b5846a37c434ffe0cae168d6b797de9087a21176f2c9ef6fa9f47aa014104b848ab6ac853cd
< Bi>
... it expects segwit merkle root of 554949ea7454928f42158d3554817f70c1fa8ba75e769faa58128ac05d333d28
< arubi>
looks like it, right. hopefully the hash in the op_return output is actually reversed like you say.. I'm not sure
< Bi>
and when you hash null hash (wtxid of coinbase) followed by this 508e4409c2cdff3d08b54370147cf6bf4d328f8248e4c60941a528b4d0375159 - I get something else
< Bi>
I was trying swapping and not swapping - no success :(
< arubi>
the merkle root is appended the witness reserved value and then hashed hash256 again
< Bi>
oh?
< Bi>
is it?
< arubi>
at least that's what I gathered from bip141
< Bi>
No, it says "A witness root hash is calculated with all those wtxid as leaves, in a way similar to the hashMerkleRoot in the block header."
< arubi>
right, and then...
< arubi>
Double-SHA256(witness root hash|witness reserved value
< arubi>
)
< Bi>
right - thank you!
< Bi>
this must be it
< arubi>
also, pretty sure that at least with the wtxid I gave you, you /should/ reverse the bytes. and also treat the bytes like they are in the commitment hash
< arubi>
(so not reversed like you pasted)
< Bi>
yes, reversing I knew about
< Bi>
Double-SHA256(witness root hash|witness reserved value) - was the part I missed
< Bi>
thanks again
< arubi>
cheers Bi
< Bi>
Yes, it works no!
< Bi>
Cheers
< arubi>
yep, tried it too :)
< Bi>
now*
< tonikt>
Is the presence of the witness root field (in the coinbase output) mandatory, after SEGWIT activation?
< tonikt>
(assuming there are any segwit txs inside the block)
< tonikt>
Sorry, I found it. It's the "unexpected-witness" code :)
< sipa>
tonikt: not, not mandatoy
< tonikt>
sipa: I think it becomes mandatory, after the activation.
< tonikt>
yes?
< tonikt>
.. it would go to "if (!fHaveWitness) ..." in ContextualCheckBlock()
< tonikt>
.. and then it would find a tx with segwit, and then it would return error "unexpected-witness"
< Victorsueca>
tonikt: non-segwit blocks are supposed to still be valid even after activation
< tonikt>
Sure. I was just wondering, after the activation, whether I have to reject blocks without the segwit root
< tonikt>
It seemed logical to reject them, but could not find that part of code
< sipa>
tonikt: no, if no transaction contains a witness, there is no requirement for a witness commitment
< tonikt>
yes - only if there is at least one witness transaction
< sipa>
of course
< sipa>
then it is mandatory
< tonikt>
but I think it also counts coinbase transaction as a possible witness-type?
< tonikt>
I have another, more high-level question...
< tonikt>
I am on testnet network now and trying to sync up the chain and all my current peers are pre 0.13.0
< tonikt>
And I am already on block #893669
< sipa>
tonikt: the coinbase witness is not committed to anywhere excet by the commitment in the output
< tonikt>
I should not be taking any block data from these peers, should I?
< sipa>
tonikt: which means that if you don't have a commitment, you can just remove the coinbase witness
< sipa>
without invalidating anything
< sipa>
we only download blocks from witness peers, indeed
< tonikt>
sipa: OK - that's interesting. I forgot that removing the witness from CB would not change txid, so it would still validate the block :)
< sipa>
indeed
< sipa>
if there is no witness commitment, it means that no tx has a witness
< sipa>
including the coinbase
< tonikt>
OK - all clear now
< tonikt>
thanks
< tonikt>
do you know any running testnet node where I could connect to fetch some segwith blocks?
< tonikt>
all my peers are < 0.13.0 now :)
< sipa>
use x9.seed.bitcoin.sipa.be
< sipa>
eh, that's mainnet
< sipa>
for testnet i think jonasschnelli's and petertodd's seed support filtering
< tonikt>
if you have a running node, would you just give me an IP, please?
< luke-jr>
sipa: some years ago, my server was blackholed semi-regularly for a while due to an upstream/backbone router hating the crawler's access patterns; could blackholing do it?
< luke-jr>
ie, maybe it thinks all IPs are sometimes terrible
< sipa>
you only have 591 good IPs
< sipa>
i have 4000
< sipa>
wow, only 3000 suddenly... perhaps due to being offline for a while as a result of that bug