diff --git a/tests/test_script.py b/tests/test_script.py index b0951662..cd857722 100644 --- a/tests/test_script.py +++ b/tests/test_script.py @@ -726,8 +726,14 @@ def test_script_verify_transaction_input_p2wsh(self): self.assertTrue(s.evaluate(message=transaction_hash, env_data=data)) def test_script_verify_transaction_input_p2pk(self): - pass - # TODO + p2pk_lockscript = '210312ed54eee6c84b440dd90623a714360196bebd842bfa64c7c7767b71b92a238dac' # key + checksig + p2pk_unlockscript = \ + ('463043021f52f02788988b941e3b810357762ccea5148e405edf124ea6b3b7eb9eba15430220609a9261612aaaa7544b7dae34' + '7b5dc3e53b0fc304957d6c4a46e1ae90a5d30001') # signature + script = p2pk_unlockscript + p2pk_lockscript + s = Script.parse_hex(script) + transaction_hash = bytes.fromhex("67b94bf5a5c17a5f6b2bedbefc51a17db669ce7ff3bbbc4943cfd876d68df986") + self.assertTrue(s.evaluate(message=transaction_hash)) def test_script_verify_transaction_output_return(self): script = bytes.fromhex('6a26062c74e4b802d60ffdd1daa37b848e39a2b0ecb2de72c6ca24d71b87813b5e056cb7f1e8c8b0') diff --git a/tests/test_transactions.py b/tests/test_transactions.py index d0360f51..b8cad4fa 100644 --- a/tests/test_transactions.py +++ b/tests/test_transactions.py @@ -1026,7 +1026,7 @@ def test_transaction_errors(self): class TestTransactionsScripts(unittest.TestCase, CustomAssertions): # def test_transaction_redeemscript_errors(self): - # exp_error = "Redeemscripts with more then 15 keys are non-standard and could result in locked up funds" + # exp_error = "Redeemscripts with more than 15 keys are non-standard and could result in locked up funds" # keys = [] # for n in range(20): # keys.append(HDKey().public_hex) @@ -1062,6 +1062,19 @@ def test_transaction_p2pk_script(self): self.assertEqual(t.inputs[0].script_type, 'signature') self.assertEqual(t.outputs[0].script_type, 'p2pk') + wif = 'tprv8ZgxMBicQKsPdx411rqb5SjGvY43Bjc2PyhU2UCVtbEwCDSyKzHhaM88XaKHe5LcyNVdwWgG9NBut4oytRLbhr7iHbJ7KxioG' \ + 'nQETYvZu3j' + k = HDKey(wif) + rawtx = ('0100000001cb7b368efcf5f17b09e9e43ec3907cbed622a5b4b33addb4c9c6f0b8ce855c9f0000000047463043021f52f0278' + '8988b941e3b810357762ccea5148e405edf124ea6b3b7eb9eba15430220609a9261612aaaa7544b7dae347b5dc3e53b0fc304' + '957d6c4a46e1ae90a5d30001ffffffff01581b00000000000023210312ed54eee6c84b440dd90623a714360196bebd842bfa6' + '4c7c7767b71b92a238dac00000000') + t = Transaction.parse_hex(rawtx, network='testnet') + t.inputs[0].keys = [k.public()] + t.update_inputs(0) + t.sign_and_update() + self.assertTrue(t.verify()) + def test_transaction_sign_uncompressed(self): ki = Key('cTuDU2P6AhB72ZrhHRnFTcZRoHdnoWkp7sSMPCBnrMG23nRNnjUX', compressed=False)