Keep P2PK scripts separate from P2PKH scripts
This makes the DB incompatible with prior versions, so the DB version is bumped.
This commit is contained in:
parent
1cf084fb69
commit
56d03625f6
10
lib/coins.py
10
lib/coins.py
@ -38,7 +38,7 @@ from hashlib import sha256
|
||||
|
||||
import lib.util as util
|
||||
from lib.hash import Base58, hash160, double_sha256, hash_to_str
|
||||
from lib.script import ScriptPubKey
|
||||
from lib.script import ScriptPubKey, OpCodes
|
||||
from lib.tx import Deserializer, DeserializerSegWit, DeserializerAuxPow, \
|
||||
DeserializerZcash, DeserializerTxTime, DeserializerReddcoin
|
||||
from server.block_processor import BlockProcessor
|
||||
@ -47,6 +47,7 @@ from server.session import ElectrumX, DashElectrumX
|
||||
|
||||
|
||||
Block = namedtuple("Block", "raw header transactions")
|
||||
OP_RETURN = OpCodes.OP_RETURN
|
||||
|
||||
|
||||
class CoinError(Exception):
|
||||
@ -131,9 +132,10 @@ class Coin(object):
|
||||
|
||||
@classmethod
|
||||
def hashX_from_script(cls, script):
|
||||
'''Returns a hashX from a script.'''
|
||||
script = ScriptPubKey.hashX_script(script)
|
||||
if script is None:
|
||||
'''Returns a hashX from a script, or None if the script is provably
|
||||
unspendable so the output can be dropped.
|
||||
'''
|
||||
if script and script[0] == OP_RETURN:
|
||||
return None
|
||||
return sha256(script).digest()[:cls.HASHX_LEN]
|
||||
|
||||
|
||||
@ -102,27 +102,6 @@ class ScriptPubKey(object):
|
||||
PayToHandlers = namedtuple('PayToHandlers', 'address script_hash pubkey '
|
||||
'unspendable strange')
|
||||
|
||||
@classmethod
|
||||
def hashX_script(cls, script):
|
||||
'''Return None if the script is provably unspendable. Return a
|
||||
pay-to-pubkey-hash script if it is pay-to-pubkey, otherwise
|
||||
return script.
|
||||
'''
|
||||
if script:
|
||||
op = script[0]
|
||||
if op == OpCodes.OP_RETURN:
|
||||
return None
|
||||
if op <= OpCodes.OP_PUSHDATA4:
|
||||
try:
|
||||
ops = Script.get_ops(script)
|
||||
except ScriptError:
|
||||
pass
|
||||
else:
|
||||
if _match_ops(ops, cls.TO_PUBKEY_OPS):
|
||||
pubkey = ops[0][1]
|
||||
script = ScriptPubKey.P2PKH_script(hash160(pubkey))
|
||||
return script
|
||||
|
||||
@classmethod
|
||||
def pay_to(cls, handlers, script):
|
||||
'''Parse a script, invoke the appropriate handler and
|
||||
|
||||
@ -32,7 +32,7 @@ class DB(util.LoggedClass):
|
||||
it was shutdown uncleanly.
|
||||
'''
|
||||
|
||||
DB_VERSIONS = [5]
|
||||
DB_VERSIONS = [6]
|
||||
|
||||
class MissingUTXOError(Exception):
|
||||
'''Raised if a mempool tx input UTXO couldn't be found.'''
|
||||
|
||||
Loading…
Reference in New Issue
Block a user