From my pybitcointools fork's issues:
I'm having some weird issues with the signature sometimes it works and other times it doesn't. When I see '[ALL]' in scriptSig that's when I know it's going to work. But I don't always get it. Any help would be great and if I find a fix, I'll send a pull request.
python tx = mktx(ins, outs) tx = mk_opreturn(hex_hash, tx) tx = sign(tx, 0, from_priv)
Here is a transaction that works:
0100000001dc4c6936943c073fca8164d8d18fdb6095ce46baff328b7e7c1230d82aaad69b010000008a473044022033f80a4c35013d5aab9d4f2763b5761188747eebb67fe15b0379f0c09b37c811022019de06d98d37da77c84bfb6f89ff2194b46a135fe8aa9677b285123b73407341014104e7919ecea9c7e9378aec49a055c532f8e0f9aea653e7c9cbe38ad2d2833a9d908f4d7bf771583f9d1e62574c42847e1aa00d506a32b9004b9b2051e3e53e2767ffffffff02803e0000000000001976a914826d9548ee793a060990bc39a01eca5521841a0988ac0000000000000000226a202c624232cdd221771294dfbb310aca000a0df6ac8b66b696d90ef06fdefb64a300000000
python {u'code': 200, u'data': {u'statistics': {u'fee': u'0.00005600', u'vins_sum': u'0.00021600', u'vouts_sum': u'0.00016000'}, u'tx': {u'locktime': 0, u'size': 266, u'txid': u'8cfa33f2eb56a443b10d929b818b01a3a3e3a970d526d212785a2b42b2d19cb9', u'version': 1, u'vin': [{u'scriptSig': {u'asm': u'3044022033f80a4c35013d5aab9d4f2763b5761188747eebb67fe15b0379f0c09b37c811022019de06d98d37da77c84bfb6f89ff2194b46a135fe8aa9677b285123b73407341[ALL] 04e7919ecea9c7e9378aec49a055c532f8e0f9aea653e7c9cbe38ad2d2833a9d908f4d7bf771583f9d1e62574c42847e1aa00d506a32b9004b9b2051e3e53e2767', u'hex': u'473044022033f80a4c35013d5aab9d4f2763b5761188747eebb67fe15b0379f0c09b37c811022019de06d98d37da77c84bfb6f89ff2194b46a135fe8aa9677b285123b73407341014104e7919ecea9c7e9378aec49a055c532f8e0f9aea653e7c9cbe38ad2d2833a9d908f4d7bf771583f9d1e62574c42847e1aa00d506a32b9004b9b2051e3e53e2767'}, u'sequence': 4294967295, u'txid': u'9bd6aa2ad830127c7e8b32ffba46ce9560db8fd1d86481ca3f073c9436694cdc', u'vout': 1}], u'vout': [{u'n': 0, u'scriptPubKey': {u'addresses': [u'1Cte7ugUwdPt3WWt5uxVfUu2dDnony8oqa'], u'asm': u'OP_DUP OP_HASH160 826d9548ee793a060990bc39a01eca5521841a09 OP_EQUALVERIFY OP_CHECKSIG', u'hex': u'76a914826d9548ee793a060990bc39a01eca5521841a0988ac', u'reqSigs': 1, u'type': u'pubkeyhash'}, u'value': 0.00016}, {u'n': 1, u'scriptPubKey': {u'asm': u'OP_RETURN 2c624232cdd221771294dfbb310aca000a0df6ac8b66b696d90ef06fdefb64a3', u'hex': u'6a202c624232cdd221771294dfbb310aca000a0df6ac8b66b696d90ef06fdefb64a3', u'type': u'nulldata'}, u'value': 0}]}}, u'message': u'', u'status': u'success'}
And here is one that doesn't:
0100000001dc4c6936943c073fca8164d8d18fdb6095ce46baff328b7e7c1230d82aaad69b010000008a4730440220da574cbdac23291faf41d5bd94ae77fe166ab7daebf1a038efa549e441af4dad02206803cadd187e6e4c80c30af06c5d7cfad327fd4d03850a539639e42dea44e8e0014104e7919ecea9c7e9378aec49a055c532f8e0f9aea653e7c9cbe38ad2d2833a9d908f4d7bf771583f9d1e62574c42847e1aa00d506a32b9004b9b2051e3e53e2767ffffffff02803e0000000000001976a914826d9548ee793a060990bc39a01eca5521841a0988ac0000000000000000226a203f79bb7b435b05321651daefd374cdc681dc06faa65e374e38337b88ca046dea00000000
python {u'code': 200, u'data': {u'statistics': {u'fee': u'0.00005600', u'vins_sum': u'0.00021600', u'vouts_sum': u'0.00016000'}, u'tx': {u'locktime': 0, u'size': 266, u'txid': u'03360c8848808714304bc14188fd2de9d40465a38dceaa153a7fcffdb5ba7a49', u'version': 1, u'vin': [{u'scriptSig': {u'asm': u'30440220da574cbdac23291faf41d5bd94ae77fe166ab7daebf1a038efa549e441af4dad02206803cadd187e6e4c80c30af06c5d7cfad327fd4d03850a539639e42dea44e8e001 04e7919ecea9c7e9378aec49a055c532f8e0f9aea653e7c9cbe38ad2d2833a9d908f4d7bf771583f9d1e62574c42847e1aa00d506a32b9004b9b2051e3e53e2767', u'hex': u'4730440220da574cbdac23291faf41d5bd94ae77fe166ab7daebf1a038efa549e441af4dad02206803cadd187e6e4c80c30af06c5d7cfad327fd4d03850a539639e42dea44e8e0014104e7919ecea9c7e9378aec49a055c532f8e0f9aea653e7c9cbe38ad2d2833a9d908f4d7bf771583f9d1e62574c42847e1aa00d506a32b9004b9b2051e3e53e2767'}, u'sequence': 4294967295, u'txid': u'9bd6aa2ad830127c7e8b32ffba46ce9560db8fd1d86481ca3f073c9436694cdc', u'vout': 1}], u'vout': [{u'n': 0, u'scriptPubKey': {u'addresses': [u'1Cte7ugUwdPt3WWt5uxVfUu2dDnony8oqa'], u'asm': u'OP_DUP OP_HASH160 826d9548ee793a060990bc39a01eca5521841a09 OP_EQUALVERIFY OP_CHECKSIG', u'hex': u'76a914826d9548ee793a060990bc39a01eca5521841a0988ac', u'reqSigs': 1, u'type': u'pubkeyhash'}, u'value': 0.00016}, {u'n': 1, u'scriptPubKey': {u'asm': u'OP_RETURN 3f79bb7b435b05321651daefd374cdc681dc06faa65e374e38337b88ca046dea', u'hex': u'6a203f79bb7b435b05321651daefd374cdc681dc06faa65e374e38337b88ca046dea', u'type': u'nulldata'}, u'value': 0}]}}, u'message': u'', u'status': u'success'}
The issue OP adds:
So I found out how to mitigate, I just have to keep changing the hash until it works. The way I'm currently doing it is by decrementing my transaction fee by one satoshi at a time. Now I need to actually fix the code. :D
Why would only certain hash values be OK to sign, but others not? I was thinking it could be a random low s issue where r is XORd if low s.