Transcript for #bitcoin-dev 2017/04/18

00:24 achow101 tomatopeel: yes. It's bytes that should have absolutely zero meaning in human readable ascii. In fact, the only places where you will actually see human readable text when converting bytes in Bitcoin related ata to ascii is in p2p message headers, the coinbase, and some OP_RETURN outputs
05:08 suryab when I'm creating a p2wkh output in a transaction, does the transaction necessarily have to have a witness associated with it? none of the other inputs/outputs are segwit
05:09 suryab i guess i should say, I created an output that is [OP_0, Hash160(pubkey)] and I want to spend that output in another transaction
05:09 suryab is that simple script all that needs to be there for me to spend it or does there need to be other information in the output for it?
05:10 achow101 to create the output, you just put the script in the output. to spend from it, you need to spend from it as specified in the BIPs, by adding stuff to the txwitness field
05:11 achow101 you do not need a txwitness in the transaction that makes the output
05:11 suryab okay cool, thanks
05:11 suryab achow101 to the rescue again
05:16 suryab so the scriptSig is what is created with spending an output. in the case of p2wkh outputs is the redeemScript just the scripPubKey of the output (i.e. the same OP_0 script?). the bitcoin core segwit dev guide says that the redeeming scriptSig should push only the redeemScript
05:21 suryab wait not that's wrong redeemscript is something else
05:36 suryab when trying to spend a p2wkh output, it says the scriptSig must be empty but the witness programm needs to have: <signature> <20-byte-key-hash>. What is the signature calculated over? Looking at the BIP page on github and the segwit dev guide on bitcoin core seems to either be talking about distinct types of outputs or the information is conflicting somehow
05:37 suryab should mention this is a version 0 p2wkh
05:42 arubi suryab, here are examples for the simple cases: https://github.com/fivepiece/witness-sig
05:43 arubi the scriptsig is supposed to be empty for p2wpkh\p2wsh and the redeeming stuff (redeemscript,signature,pubkey) should be in the witness
05:44 arubi scriptsig will have the witness programitself (the preimage to a p2sh hash160) if the scritpubkeys for p2wsh\p2wpkh are nested in p2sh
05:44 arubi other than that, the signature is done over the exact same data
05:45 arubi (I mean, a signature redeeming p2sh(p2wpkh) is the same for just bare p2wpkh, just add the p2sh redeemscript in scriptsig for p2sh() nests)
05:45 suryab oh perfect, thanks. i'm not nesting my transactions
05:45 arubi you don't have to really
05:46 suryab yeah i didn't think so
05:46 suryab my main goal in creating these txs is so that I can do my experimenting on testnet and get around the ongoing malleability attack
05:47 suryab so i'm hoping that I'm satisfying the minimum required to get around that, but i suppose it depends on how many nodes on testnet are actually updated to accept/realy segwit transactions
05:47 suryab relay*
05:47 arubi segwit is pretty much supported by testnet nodes
05:48 arubi well, sometimes there are miners who don't include segwit transactions, but eventually it'll get mined. you can also use a local regtest. I'm off to work, cya around!
05:49 suryab thanks for the help!
06:16 suryab when creating the witness is the only thing in the witness script <signature hash> <20-byte-key-hash> or is there more to add? more importantly, is the signature hash created in the same way over the entire new transaction with SIGHASH_ALL?
11:44 tomatopeel hey I'm going through this series http://davidederosa.com/basic-blockchain-programming , I'm on the 2nd and 3rd part re: serialization of fixed length and variable length data, the author gives no examples of use cases for this though so it's a bit hard to conceptualise. So what are some examples for use cases for serialization of fixed length and variable length data?
12:47 Chris_Stewart_5 tomatopeel: I'm not sure why they talk about fixed length data, but for variable length data we have a 'VarInt' data structure in the protocol
12:49 Chris_Stewart_5 IIRC it is called 'CVarInt' in bitcoin core
13:13 tomatopeel oh ty
13:35 Chris_Stewart_5 tomatopeel: An example of variable length data is script signatures. A multisig script signature requires more bytes than a single signature script signature.
18:21 suryab when is there anything special that I need to include in inv messages when i am sending transactions that have a witness?
18:22 suryab well... do i include the txid or the wid in the inv message? or both?
18:31 goatpig txid afaik
18:31 goatpig if you inv'ing a witness tx
18:31 goatpig you need to use the witness tx inv packet
18:33 goatpig which is 1 | (1 << 30)
18:33 goatpig basically inv_tx type with the witness bit flag
18:38 suryab okay i guess my new question is that i get bad-txns-vin-empty rejects from most nodes on the network when I just send them a tx message without inv'ing. Is that because of the type of segwit output I'm using (p2wkh) or would that indicate a lack of segwit adoption?
18:39 suryab is the most common accepted type nesting p2wkh inside of a p2sh?
18:39 suryab p2sh-p2wkh
18:42 suryab some testnet block explorers seem to accept it
18:42 suryab but most nodes, appro 111 of the nodes gave me that reject message
18:47 arubi I'm sure the type of nesting isn't related
18:47 goatpig err
18:47 arubi and block explorers shouldn't be your measure for anything.. it's coincidence that they sometime display the correct data :)
18:47 goatpig when you ver a node you get to see if its support SW in its services
18:48 goatpig regardless you should inv before you push a getdata payload
18:49 goatpig and in particular, the inv type should be inv_tx_witness so at to make sure non supporting nodes don't request the getdata packet
18:50 goatpig as for your vin-empty issue
18:50 goatpig it's possible you didn't serialize your tx as SW
18:50 goatpig are you missing the flag and marker maybe?
18:50 arubi well I think that the flag is there
18:50 arubi it "looks" like 0 vin for non segwit nodes
18:50 goatpig sure but it's suprising to me
18:51 goatpig the grand majority of nodes on testnet are SW aware
18:51 arubi yep, that's where I'm lost too
18:51 goatpig and providing a SW tx from a inv_tx packet should still work
18:51 goatpig even though it's not "clean" signaling
18:53 arubi maybe best to see what the transaction being sent is first, maybe it's just not funded correctly and missing any input
18:54 goatpig at this rate, bounce the tx between 2 of your nodes
19:23 adiabat arubi: block explorers are a mess but smartbit does seem to work OK with segwit txs
19:24 adiabat https://testnet.smartbit.com.au/txs/decodetx can be useful to see if their software can parse it
19:25 arubi adiabat, yep! smarbit does a very good job I agree
19:36 suryab https://testnet.smartbit.com.au/tx/aa3c950a01e7f40bd5c55b5b410f2e8ab3f0c43ebfc09cfd1ef4d0769b592907
19:36 suryab http://n.bitcoin.ninja/checktx
19:36 suryab this is what i used to see if the outputs are interpretted as segwit outputs first off and the second link i was linked to on this irc channel before as a good place to check
19:37 suryab check validity of transcations that spend seg wit outputs
19:38 suryab also i should point out that my local node accepts the transaction when i use the sendtrawtransaction rpc call, i know it does some level of validation before checking it
19:40 suryab transaction that I actually sent out: 010000000001010729599b76d0f41efd9cc0bf3ec4f0b38a2e0f415b5bc5d50bf4e7010a953caa0100000000ffffffff0154150000000000001600149eea64b8d79d147b884cc0a8ec7de357f5dfc9df024730440220784c3ae3e62b6301968e8ca2f43890306fbf782d15ff2ae8ca844735c21825f8022003fe8747d572ed8c73feb4202b306ee7211becc53a005ab047dd69d67ab84538012103b561b2cfad4e639a689c05e3cad6a7e76f8e703a9d47bcf03b89ac9e3ceb25ae00000000
19:42 suryab after some tinkering the checktx link finally accepted as valid and when i sent it out my local node didn't complain. if it's worth anything the validation on checktx link and my node seems to be similar as they both responded the same way to every serialized tx i put into both (in terms of reject/accept)
19:42 suryab arubi: yes I've been using smartbit as a sort of validation to see if my segwit outputs are being interpretted correctly
19:43 suryab meant to ref adiabat
19:47 suryab deserialized for readability: CTransaction((CTxIn(COutPoint(lx('aa3c950a01e7f40bd5c55b5b410f2e8ab3f0c43ebfc09cfd1ef4d0769b592907'), 1), CScript([]), 0xffffffff),), (CTxOut(0.0000546*COIN, CScript([0, x('9eea64b8d79d147b884cc0a8ec7de357f5dfc9df')])),), 0, 1, CTxWitness(CTxInWitness(CScriptWitness(x('30440220784c3ae3e62b6301968e8ca2f43890306fbf782d15ff2ae8ca844735c21825f8022003fe8747d572ed8c73feb4202b306ee7211becc53a005ab047dd69d67
20:19 arubi is this redeeming a testnet input?
20:19 arubi I mean, is the input to this confirmed at all?
20:20 arubi I don't have it so I'm wondering what's being redeemed here
20:25 arubi oh I'm sorry, I missed the link ^, now why is the input txid not found
20:26 arubi AA3C950A01E7F40BD5C55B5B410F2E8AB3F0C43EBFC09CFD1EF4D0769B592907
20:26 arubi aa3c950a01e7f40bd5c55b5b410f2e8ab3f0c43ebfc09cfd1ef4d0769b592907
20:28 arubi oh, my fat fingered locally. sorry
22:37 suryab back
22:38 suryab i should've said I'd be gone i probably missed what was said about my question up until someone suggested smartbit block explorer