def test_from_bare_checksig_scriptPubKey(self): def T(hex_scriptpubkey, expected_str_address): scriptPubKey = CScript(x(hex_scriptpubkey)) # test that CBitcoinAddressError is raised, we do not support # bare checksig with self.assertRaises(CBitcoinAddressError): P2PKHBitcoinAddress.from_scriptPubKey(scriptPubKey) # compressed T( '21000000000000000000000000000000000000000000000000000000000000000000ac', '14p5cGy5DZmtNMQwTQiytBvxMVuTmFMSyU') # uncompressed T( '410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ac', '13VmALKHkCdSN1JULkP6RqW3LcbpWvgryV') # non-canonical encoding T( '4c21000000000000000000000000000000000000000000000000000000000000000000ac', '14p5cGy5DZmtNMQwTQiytBvxMVuTmFMSyU') # odd-lengths are *not* accepted with self.assertRaises(CBitcoinAddressError): P2PKHBitcoinAddress.from_scriptPubKey( CScript( x('2200000000000000000000000000000000000000000000000000000000000000000000ac' )))
def test_from_non_canonical_scriptPubKey(self) -> None: def T(hex_scriptpubkey: str, expected_str_address: str) -> None: scriptPubKey = CScript(x(hex_scriptpubkey)) # now test that CBitcoinAddressError is raised, non-canonical # pushdata is not allowed with self.assertRaises(CBitcoinAddressError): P2PKHBitcoinAddress.from_scriptPubKey(scriptPubKey) T('76a94c14000000000000000000000000000000000000000088ac', '1111111111111111111114oLvT2') T('76a94d1400000000000000000000000000000000000000000088ac', '1111111111111111111114oLvT2') T('76a94e14000000000000000000000000000000000000000000000088ac', '1111111111111111111114oLvT2') # make sure invalid scripts raise CBitcoinAddressError with self.assertRaises(CBitcoinAddressError): P2PKHBitcoinAddress.from_scriptPubKey(CScript(x('76a94c14')))
def T(hex_scriptpubkey: str, expected_str_address: str) -> None: scriptPubKey = CScript(x(hex_scriptpubkey)) # test that CBitcoinAddressError is raised, we do not support # bare checksig with self.assertRaises(CBitcoinAddressError): P2PKHBitcoinAddress.from_scriptPubKey(scriptPubKey)
def T(hex_scriptpubkey: str, expected_str_address: str) -> None: scriptPubKey = CScript(x(hex_scriptpubkey)) # now test that CBitcoinAddressError is raised, non-canonical # pushdata is not allowed with self.assertRaises(CBitcoinAddressError): P2PKHBitcoinAddress.from_scriptPubKey(scriptPubKey)