1 2017-12-22 09:20:56 <arubi> is brianddk \ Dan Bryant around?  interested in what's going to be in scope of this signmessage bip : https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-December/015452.html
 2 2017-12-22 17:32:07 <DSidH> I am having some trouble in creating the standard P2SH tx given in BIP16
 3 2017-12-22 17:32:30 <DSidH> explained here https://bitcoin.stackexchange.com/q/66197/2075
 4 2017-12-22 17:32:35 <DSidH> any help will be appreciated
 5 2017-12-22 17:32:54 <DSidH> getting this error in sendrawtransaction -> 16: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)
 6 2017-12-22 17:33:25 <arubi> seems like you're getting the correct script
 7 2017-12-22 17:33:29 <arubi> just wrong signature
 8 2017-12-22 17:33:54 <DSidH> the script is [pubKey] [OP_CHECKSIG]
 9 2017-12-22 17:34:15 <arubi> what are you signing exactly?
10 2017-12-22 17:34:23 <arubi> the actual midstate
11 2017-12-22 17:34:59 <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
12 2017-12-22 17:35:27 <DSidH> the scriptSig as:  [0x00] [{sigSize, sig}] [{pubKeySize, pubKey}] [OP_CHECKSIG]
13 2017-12-22 17:35:42 <arubi> yea I know how to do that, but did you get?
14 2017-12-22 17:35:59 <DSidH> I am not 100% sure what the temp scriptSig to use for signing
15 2017-12-22 17:36:20 <DSidH> so I am using the orig redeemScript
16 2017-12-22 17:36:34 <DSidH> from what I understood after searching online
17 2017-12-22 17:36:39 <arubi> oh that can't be right
18 2017-12-22 17:36:40 <arubi> "asm": "0 3045022100d51f8d9bfeb7bc6108facaae131dcf875493a1768a55310fcfaec7848a37e679022074eddfef1b3b64348a7d4436e0bdfcff639c5051701758d5dea6172675c62098[ALL] 039f53e45f8f18b8ed294378bda342eff69b2053debf27fbede7d2d6bd84be6235 OP_CHECKSIG"
19 2017-12-22 17:36:40 <arubi> "scriptSig": {
20 2017-12-22 17:36:40 <arubi> "txid": "e434a13cac79dc3d26e7279bff05c0f071a2df03e2ba6ca13c88f0e82dca9998",
21 2017-12-22 17:36:40 <arubi> "vout": 0,
22 2017-12-22 17:36:58 <arubi> there's a checksig op in scriptsig?  that's not gonna work
23 2017-12-22 17:37:10 <DSidH> I tried with and without :P
24 2017-12-22 17:37:18 <arubi> if you want the redeemscript threre, you need to push the serialization of it
25 2017-12-22 17:37:19 <DSidH> last attempt was to add checksig
26 2017-12-22 17:37:37 <DSidH> so I need to add that many bytes to push
27 2017-12-22 17:37:42 <DSidH> lemme try that
28 2017-12-22 17:50:52 <DSidH> arubi: I am getting a different error now: 64: non-mandatory-script-verify-flag (unknown error)
29 2017-12-22 17:51:34 <DSidH> here is raw tx -> https://pastebin.com/raw/1jTAnA3v
30 2017-12-22 17:52:42 <arubi> that means that the redeemscript is wrong
31 2017-12-22 17:53:52 <DSidH> hmm what am I doing wrong? is there any example of bip16 [pubkey] [OP_CHECKSIG] .. its described here https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki
32 2017-12-22 17:54:05 <DSidH> but I could not find examples anywhere
33 2017-12-22 17:54:11 <arubi> I'm looking into it
34 2017-12-22 17:55:08 <arubi> looks correct, lemme see
35 2017-12-22 18:01:03 <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
36 2017-12-22 18:01:08 <arubi> looking :)
37 2017-12-22 18:01:44 <DSidH> ok if I can narrow it down to signature it will be helpful, as long as the rest of the tx is proper
38 2017-12-22 18:02:27 <arubi> oh
39 2017-12-22 18:03:05 <arubi> no wait, yea the signatures are good
40 2017-12-22 18:03:37 <arubi> you know what let me double check for policy stuff..  I might have turned everything off on regtest
41 2017-12-22 18:04:31 <DSidH> I am also checking for high s values
42 2017-12-22 18:04:49 <arubi> doesn't look like s is high
43 2017-12-22 18:15:58 <DSidH> could it be something to with sighash_type? like I may be setting it when its not needed
44 2017-12-22 18:18:21 <arubi> what are you setting?
45 2017-12-22 18:18:31 <arubi> seems like 'ALL'
46 2017-12-22 18:18:47 <arubi> can you just post the actual thing that you're hashing for signage? :)
47 2017-12-22 18:19:34 <arubi> ah nevermind, the signatures are good
48 2017-12-22 18:20:33 <arubi> looking into the sigs..
49 2017-12-22 18:20:37 <DSidH> nvm I tried removing and it gave invalid sig
50 2017-12-22 18:20:48 <DSidH> so seems flafs are good.  I am setting sighash_all
51 2017-12-22 18:20:56 <DSidH> flags*
52 2017-12-22 18:21:24 <arubi> right that's what you should set really
53 2017-12-22 18:22:09 <arubi> yea sigs are okay, checked outside of core too
54 2017-12-22 18:29:31 <arubi> the transaction is good when not in context of testnet, at least least it seems that way..  fwiw https://pastebin.com/raw/th6je4Ly .  I'm still looking, this is interesting :)
55 2017-12-22 18:37:53 <arubi> oh wait
56 2017-12-22 18:38:07 <arubi> no, sorry, just different sig
57 2017-12-22 18:38:16 <arubi> (not sure how you came up with the k values)
58 2017-12-22 18:39:46 <arubi> oh DSidH
59 2017-12-22 18:39:57 <arubi> you have an extra 0x00 byte at the beginning of scriptsig
60 2017-12-22 18:40:30 <DSidH> 1 min checkin
61 2017-12-22 18:41:24 <DSidH> I thought that was by design. that we have to put OP_0
62 2017-12-22 18:41:46 <arubi> only on checkmultisig you need that
63 2017-12-22 18:42:07 <DSidH> arubi: oh ! :)
64 2017-12-22 18:42:13 <DSidH> thanks the tx was sent !
65 2017-12-22 18:42:18 <arubi> well, almost any dumb value works, but 0 is used.  cheers :)
66 2017-12-22 18:42:30 <DSidH> well I learned a lot though.. ty
67 2017-12-22 18:42:43 <arubi> and I learned that 0x00 is easy to miss
68 2017-12-22 18:45:01 <arubi> DSidH, you don't mind that I answered the se post right :)
69 2017-12-22 18:45:47 <arubi> oh you know what, I answered as if you posted this error 64 issue
70 2017-12-22 18:47:33 <arubi> fixing..
71 2017-12-22 18:50:34 <DSidH> no problem. Please do answer
72 2017-12-22 18:51:17 <DSidH> now I can move on to segwit :)
73 2017-12-22 18:51:18 <arubi> answered and added the reason why it worked on my regtest node
74 2017-12-22 18:51:34 <arubi> segwit is so much better, you'll see
75 2017-12-22 18:52:22 <DSidH> also accepted. I'll clean up the question in a bit
76 2017-12-22 18:52:45 <arubi> sweet
77 2017-12-22 19:50:16 <sinasafaee-rad> hi everyone
78 2017-12-22 21:01:33 <DSidH> From segwit developer guide:
79 2017-12-22 21:01:40 <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
80 2017-12-22 21:01:45 <DSidH> what exactly is scriptCode?
81 2017-12-22 21:06:00 <DSidH> nvm: think this explains it https://bitcoin.stackexchange.com/a/57997/2075
82 2017-12-22 23:22:02 <Sentineo> why is offset for diff 1 calculated as 0xffff * 2**208 ? What does that 'offset' mean
83 2017-12-22 23:22:05 <Sentineo> here?
84 2017-12-22 23:23:03 <Sentineo> https://en.bitcoin.it/wiki/Difficulty ... it ks giving me a headache ;)
85 2017-12-22 23:31:07 <laudiacay> hiya where are good bitcoin APIs?
86 2017-12-22 23:31:36 <laudiacay> i wanna be able to fetch transaction prices