Transcript for #bitcoin-dev 2017/12/22

09:20 arubi is brianddk \ Dan Bryant around? interested in what's going to be in scope of this signmessage bip :
17:32 DSidH I am having some trouble in creating the standard P2SH tx given in BIP16
17:32 DSidH explained here
17:32 DSidH any help will be appreciated
17:32 DSidH getting this error in sendrawtransaction -> 16: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)
17:33 arubi seems like you're getting the correct script
17:33 arubi just wrong signature
17:33 DSidH the script is [pubKey] [OP_CHECKSIG]
17:34 arubi what are you signing exactly?
17:34 arubi the actual midstate
17:34 DSidH I created the tx as follows: Create unsigned transactions with all scriptSigs empty For each input to sign, set its scriptSig to redeemScript: 21039F53E45F8F18B8ED294378BDA342EFF69B2053DEBF27FBEDE7D2D6BD84BE6235AC, keeping other scriptSigs to empty. Serialize the new tx and append SIGHASHALL bytes (0x01) in little endian 4 bytes Double Sha256 above and sign resulting value. Add one byte 0x01 to signature to indicate SIGHASH_ALL. L
17:35 DSidH the scriptSig as: [0x00] [{sigSize, sig}] [{pubKeySize, pubKey}] [OP_CHECKSIG]
17:35 arubi yea I know how to do that, but did you get?
17:35 DSidH I am not 100% sure what the temp scriptSig to use for signing
17:36 DSidH so I am using the orig redeemScript
17:36 DSidH from what I understood after searching online
17:36 arubi oh that can't be right
17:36 arubi "txid": "e434a13cac79dc3d26e7279bff05c0f071a2df03e2ba6ca13c88f0e82dca9998",
17:36 arubi "vout": 0,
17:36 arubi "scriptSig": {
17:36 arubi "asm": "0 3045022100d51f8d9bfeb7bc6108facaae131dcf875493a1768a55310fcfaec7848a37e679022074eddfef1b3b64348a7d4436e0bdfcff639c5051701758d5dea6172675c62098[ALL] 039f53e45f8f18b8ed294378bda342eff69b2053debf27fbede7d2d6bd84be6235 OP_CHECKSIG"
17:36 arubi there's a checksig op in scriptsig? that's not gonna work
17:37 DSidH I tried with and without :P
17:37 arubi if you want the redeemscript threre, you need to push the serialization of it
17:37 DSidH last attempt was to add checksig
17:37 DSidH so I need to add that many bytes to push
17:37 DSidH lemme try that
17:50 DSidH arubi: I am getting a different error now: 64: non-mandatory-script-verify-flag (unknown error)
17:51 DSidH here is raw tx ->
17:52 arubi that means that the redeemscript is wrong
17:53 DSidH hmm what am I doing wrong? is there any example of bip16 [pubkey] [OP_CHECKSIG] .. its described here
17:54 DSidH but I could not find examples anywhere
17:54 arubi I'm looking into it
17:55 arubi looks correct, lemme see
18:01 arubi now it's even weirder. I can verify your transaction on a local regtest node, but testnet fails with the same error you're getting
18:01 arubi looking :)
18:01 DSidH ok if I can narrow it down to signature it will be helpful, as long as the rest of the tx is proper
18:02 arubi oh
18:03 arubi no wait, yea the signatures are good
18:03 arubi you know what let me double check for policy stuff.. I might have turned everything off on regtest
18:04 DSidH I am also checking for high s values
18:04 arubi doesn't look like s is high
18:15 DSidH could it be something to with sighash_type? like I may be setting it when its not needed
18:18 arubi what are you setting?
18:18 arubi seems like 'ALL'
18:18 arubi can you just post the actual thing that you're hashing for signage? :)
18:19 arubi ah nevermind, the signatures are good
18:20 arubi looking into the sigs..
18:20 DSidH nvm I tried removing and it gave invalid sig
18:20 DSidH so seems flafs are good. I am setting sighash_all
18:20 DSidH flags*
18:21 arubi right that's what you should set really
18:22 arubi yea sigs are okay, checked outside of core too
18:29 arubi the transaction is good when not in context of testnet, at least least it seems that way.. fwiw . I'm still looking, this is interesting :)
18:37 arubi oh wait
18:38 arubi no, sorry, just different sig
18:38 arubi (not sure how you came up with the k values)
18:39 arubi oh DSidH
18:39 arubi you have an extra 0x00 byte at the beginning of scriptsig
18:40 DSidH 1 min checkin
18:41 DSidH I thought that was by design. that we have to put OP_0
18:41 arubi only on checkmultisig you need that
18:42 DSidH arubi: oh ! :)
18:42 DSidH thanks the tx was sent !
18:42 arubi well, almost any dumb value works, but 0 is used. cheers :)
18:42 DSidH well I learned a lot though.. ty
18:42 arubi and I learned that 0x00 is easy to miss
18:45 arubi DSidH, you don't mind that I answered the se post right :)
18:45 arubi oh you know what, I answered as if you posted this error 64 issue
18:47 arubi fixing..
18:50 DSidH no problem. Please do answer
18:51 DSidH now I can move on to segwit :)
18:51 arubi answered and added the reason why it worked on my regtest node
18:51 arubi segwit is so much better, you'll see
18:52 DSidH also accepted. I'll clean up the question in a bit
18:52 arubi sweet
19:50 sinasafaee-rad hi everyone
21:01 DSidH From segwit developer guide:
21:01 DSidH Please note that for a P2SH-P2WPKH, the scriptCode is always 26 bytes including the leading size byte, as 0x1976a914{20-byte keyhash}88ac, NOT the redeemScript nor scriptPubKey
21:01 DSidH what exactly is scriptCode?
21:06 DSidH nvm: think this explains it
23:22 Sentineo why is offset for diff 1 calculated as 0xffff * 2**208 ? What does that 'offset' mean
23:22 Sentineo here?
23:23 Sentineo ... it ks giving me a headache ;)
23:31 laudiacay hiya where are good bitcoin APIs?
23:31 laudiacay i wanna be able to fetch transaction prices