Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_signrawtransaction.py
Show All 20 Lines | class SignRawTransactionsTest(BitcoinTestFramework): | ||||
def successful_signing_test(self): | def successful_signing_test(self): | ||||
"""Creates and signs a valid raw transaction with one input. | """Creates and signs a valid raw transaction with one input. | ||||
Expected results: | Expected results: | ||||
1) The transaction has a complete set of signatures | 1) The transaction has a complete set of signatures | ||||
2) No script verification error occurred""" | 2) No script verification error occurred""" | ||||
self.log.info("Test valid raw transaction with one input") | |||||
privKeys = ['cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N', | privKeys = ['cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N', | ||||
'cVKpPfVKSJxKqVpE9awvXNWuLHCa5j5tiE7K6zbUSptFpTEtiFrA'] | 'cVKpPfVKSJxKqVpE9awvXNWuLHCa5j5tiE7K6zbUSptFpTEtiFrA'] | ||||
inputs = [ | inputs = [ | ||||
# Valid pay-to-pubkey scripts | # Valid pay-to-pubkey scripts | ||||
{'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', | {'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', | ||||
'vout': 0, 'amount': 3.14159, | 'vout': 0, 'amount': 3.14159, | ||||
'scriptPubKey': '76a91460baa0f494b38ce3c940dea67f3804dc52d1fb9488ac'}, | 'scriptPubKey': '76a91460baa0f494b38ce3c940dea67f3804dc52d1fb9488ac'}, | ||||
Show All 10 Lines | def successful_signing_test(self): | ||||
# 1) The transaction has a complete set of signatures | # 1) The transaction has a complete set of signatures | ||||
assert rawTxSigned['complete'] | assert rawTxSigned['complete'] | ||||
# 2) No script verification error occurred | # 2) No script verification error occurred | ||||
assert 'errors' not in rawTxSigned | assert 'errors' not in rawTxSigned | ||||
def test_with_lock_outputs(self): | def test_with_lock_outputs(self): | ||||
"""Test correct error reporting when trying to sign a locked output""" | self.log.info( | ||||
"Test correct error reporting when trying to sign a locked output") | |||||
self.nodes[0].encryptwallet("password") | self.nodes[0].encryptwallet("password") | ||||
rawTx = '020000000156b958f78e3f24e0b2f4e4db1255426b0902027cb37e3ddadb52e37c3557dddb0000000000ffffffff01c0a6b929010000001600149a2ee8c77140a053f36018ac8124a6ececc1668a00000000' | rawTx = '020000000156b958f78e3f24e0b2f4e4db1255426b0902027cb37e3ddadb52e37c3557dddb0000000000ffffffff01c0a6b929010000001600149a2ee8c77140a053f36018ac8124a6ececc1668a00000000' | ||||
assert_raises_rpc_error(-13, | assert_raises_rpc_error(-13, | ||||
"Please enter the wallet passphrase with walletpassphrase first", | "Please enter the wallet passphrase with walletpassphrase first", | ||||
self.nodes[0].signrawtransactionwithwallet, | self.nodes[0].signrawtransactionwithwallet, | ||||
rawTx) | rawTx) | ||||
def script_verification_error_test(self): | def script_verification_error_test(self): | ||||
"""Creates and signs a raw transaction with valid (vin 0), invalid (vin 1) and one missing (vin 2) input script. | """Creates and signs a raw transaction with valid (vin 0), invalid (vin 1) and one missing (vin 2) input script. | ||||
Expected results: | Expected results: | ||||
3) The transaction has no complete set of signatures | 3) The transaction has no complete set of signatures | ||||
4) Two script verification errors occurred | 4) Two script verification errors occurred | ||||
5) Script verification errors have certain properties ("txid", "vout", "scriptSig", "sequence", "error") | 5) Script verification errors have certain properties ("txid", "vout", "scriptSig", "sequence", "error") | ||||
6) The verification errors refer to the invalid (vin 1) and missing input (vin 2)""" | 6) The verification errors refer to the invalid (vin 1) and missing input (vin 2)""" | ||||
self.log.info("Test script verification errors") | |||||
privKeys = ['cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N'] | privKeys = ['cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N'] | ||||
inputs = [ | inputs = [ | ||||
# Valid pay-to-pubkey script | # Valid pay-to-pubkey script | ||||
{'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', | {'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', | ||||
'vout': 0, 'amount': 0}, | 'vout': 0, 'amount': 0}, | ||||
# Invalid script | # Invalid script | ||||
{'txid': '5b8673686910442c644b1f4993d8f7753c7c8fcb5c87ee40d56eaeef25204547', | {'txid': '5b8673686910442c644b1f4993d8f7753c7c8fcb5c87ee40d56eaeef25204547', | ||||
▲ Show 20 Lines • Show All 178 Lines • Show Last 20 Lines |