diff --git a/tests/test_pycctx.py b/tests/test_pycctx.py index 7ccfe2c..795e465 100644 --- a/tests/test_pycctx.py +++ b/tests/test_pycctx.py @@ -227,3 +227,45 @@ def test_cc_tx(): assert cond_in.to_anon().to_py() == cond.to_anon().to_py() assert cond_out.to_anon().to_py() == cond.to_anon().to_py() + +# {'type': 'threshold-sha-256', 'threshold': 2, 'subconditions': [{'type': 'threshold-sha-256', 'threshold': 1, 'subconditions': [{'type': 'secp256k1-sha-256', 'pubkey': '03682b255c40d0cde8faee381a1a50bbb89980ff24539cb8518e294d3a63cefe12', 'signature': '3956faf39b6c3d051e03f883dc9067ede9fce0d29f13d3a9b8b59775ca874e8357a66829ad7c41712303c48e3a5dda40d5e25e641f45436e51a7ff2616fdc6de'}]}, {'type': 'eval-sha-256', 'code': 'e4'}]} +def test_single_eval_sign(): + known_good = Tx.decode('0400008085202f890165d39086d693c38845e703b30b9c39664fd9038e29378f428ca8383a9b39c7c4000000007b4c79a276a072a26ba067a565802103682b255c40d0cde8faee381a1a50bbb89980ff24539cb8518e294d3a63cefe1281403956faf39b6c3d051e03f883dc9067ede9fce0d29f13d3a9b8b59775ca874e8357a66829ad7c41712303c48e3a5dda40d5e25e641f45436e51a7ff2616fdc6dea100af038001e4a10001ffffffff04700c023b00000000302ea22c8020e029c511da55523565835887e412e5a0c9b920801b007000df45e545f25028248103120c008203000401cc80969800000000002321028d84d184f18bcdf3f10086615f3d8b47b7ad7855e02a478c6de5e4fced7219f5ac00000000000000002321028d84d184f18bcdf3f10086615f3d8b47b7ad7855e02a478c6de5e4fced7219f5ac0000000000000000086a06e44755de8b0b00000000520100000000000000000000000000') + + vin_cond = known_good.inputs[0].script.parse_condition() + vouts_good = known_good.outputs + + mtx = Tx( + inputs = [ + TxIn(known_good.inputs[0].previous_output, ScriptSig.from_condition(vin_cond), + input_amount=1000000000) + ], + outputs = known_good.outputs + ) + mtx.expiry_height = known_good.expiry_height + mtx.lock_time = known_good.lock_time + mtx.version = known_good.version + mtx.sign(['Uw8FWra4tCu3LYYosVDjLHkbkKuuRgXEo6yy6bdf8w4S7sjzsPwd']) + + assert mtx.hash == known_good.hash + +# {'type': 'threshold-sha-256', 'threshold': 3, 'subconditions': [{'type': 'threshold-sha-256', 'threshold': 1, 'subconditions': [{'type': 'secp256k1-sha-256', 'pubkey': '03682b255c40d0cde8faee381a1a50bbb89980ff24539cb8518e294d3a63cefe12', 'signature': 'b768f3ea235aae45ccad0d7b6907a6c45b22ab9b16eeee7db38bb2a181d576317aa18fa8664eaf5d16c7a676b189bbd6ecce9291fcd48e77940574beb6b8ee20'}]}, {'type': 'eval-sha-256', 'code': 'e4'}, {'type': 'eval-sha-256', 'code': 'e5'}]} +def test_multi_eval_sign(): + known_good = Tx.decode('0400008085202f89014fe6c09690775e980410feb5300e8be27b8c0f84b92ad874ab94bbd3e2371c0e00000000804c7ea27ba077a26ba067a565802103682b255c40d0cde8faee381a1a50bbb89980ff24539cb8518e294d3a63cefe128140b768f3ea235aae45ccad0d7b6907a6c45b22ab9b16eeee7db38bb2a181d576317aa18fa8664eaf5d16c7a676b189bbd6ecce9291fcd48e77940574beb6b8ee20a100af038001e4af038001e5a10001ffffffff04700c023b00000000302ea22c80208666071e49c77ae44964ed3a67fab598e9de358305195412b7de686afdd817f781032210008203000401cc80969800000000002321028d84d184f18bcdf3f10086615f3d8b47b7ad7855e02a478c6de5e4fced7219f5ac00000000000000002321028d84d184f18bcdf3f10086615f3d8b47b7ad7855e02a478c6de5e4fced7219f5ac0000000000000000086a06e44767458b0b00000000510100000000000000000000000000') + + vin_cond = known_good.inputs[0].script.parse_condition() + vouts_good = known_good.outputs + + mtx = Tx( + inputs = [ + TxIn(known_good.inputs[0].previous_output, ScriptSig.from_condition(vin_cond), + input_amount=1000000000) + ], + outputs = known_good.outputs + ) + mtx.expiry_height = known_good.expiry_height + mtx.lock_time = known_good.lock_time + mtx.version = known_good.version + mtx.sign(['Uw8FWra4tCu3LYYosVDjLHkbkKuuRgXEo6yy6bdf8w4S7sjzsPwd']) + + assert mtx.hash == known_good.hash