Beispiel #1
0
    "NAMESPACE_PREORDER",
    "NAME_PREORDER",
    "NAME_RENEWAL"
]

# set of ops that have no state to record 
OPCODE_STATELESS_OPS = [
    "ANNOUNCE"
]


NAMESPACE_LIFE_INFINITE = 0xffffffff

# default burn address for fees (the address of public key 0x0000000000000000000000000000000000000000)
BLOCKSTACK_BURN_PUBKEY_HASH = "0000000000000000000000000000000000000000"
BLOCKSTACK_BURN_ADDRESS = virtualchain.hex_hash160_to_address( BLOCKSTACK_BURN_PUBKEY_HASH )   # "1111111111111111111114oLvT2"

# default namespace record (i.e. for names with no namespace ID)
NAMESPACE_DEFAULT = {
   'opcode': 'NAMESPACE_REVEAL',
   'lifetime': EXPIRATION_PERIOD,
   'coeff': 15,
   'base': 15,
   'buckets': [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],
   'version': NAMESPACE_VERSION_PAY_TO_BURN,
   'nonalpha_discount': 1.0,
   'no_vowel_discount': 1.0,
   'namespace_id': None,
   'namespace_id_hash': None,
   'sender': "",
   'recipient': "",
Beispiel #2
0
def parse_nameop( opcode, payload, fake_pubkey, recipient=None, recipient_address=None, import_update_hash=None, burn_address=None, reveal_address=None ):

    opcode_name = OPCODE_NAMES[opcode]
    pubk = virtualchain.BitcoinPublicKey(fake_pubkey)
    address = pubk.address()
    script_pubkey = virtualchain.make_payment_script( address )
    senders = [{
        "script_pubkey": script_pubkey,
        "script_type": "pubkeyhash",
        "addresses": [ address ]
    }]

    # just enough to get the public key
    inputs = [{
        'script': 'ignored {}'.format(fake_pubkey).encode('hex')
    }]

    script = "OP_RETURN %s" % payload

    try:
        scripthex = virtualchain.make_data_script(binascii.hexlify(payload))
    except:
        if len(payload) == 0:
            scripthex = "6a"
        else:
            print 'failed on {}'.format(payload)
            raise

    outputs = [{
        'script': scripthex,
        'value': 0
    }]

    if recipient_address is not None:
        script = "OP_DUP OP_HASH160 %s OP_EQUALVERIFY OP_CHECKSIG" % binascii.hexlify( virtualchain.lib.hashing.bin_double_sha256( fake_pubkey ) )
        scripthex = virtualchain.make_payment_script( recipient_address )
        outputs.append( {
            'script': scripthex,
            "value": 10000000
        })

    if import_update_hash is not None:
        script = "OP_DUP OP_HASH160 %s OP_EQUALVERIFY OP_CHECKSIG" % import_update_hash
        scripthex = virtualchain.make_payment_script( virtualchain.hex_hash160_to_address( import_update_hash ) )
        outputs.append( {
            "script": scripthex,
            "value": 10000000
        })

    elif burn_address is not None:
        scripthex = virtualchain.make_payment_script( burn_address )
        outputs.append( {
            "script": scripthex,
            "value": 10000000
        })
    
    elif reveal_address is not None:
        scripthex = virtualchain.make_payment_script( reveal_address )
        outputs.append( {
            "script": scripthex,
            "value": 10000000
        })

    try:
        op = op_extract( opcode_name, payload, senders, inputs, outputs, 488501, 0, "00" * 64 )  
    except AssertionError, ae:
        # failed to parse
        return None

# a few contants borrowed from Blockstack Core
LENGTH_VALUE_HASH = 20
LENGTH_CONSENSUS_HASH = 16
LENGTH_MAX_NAME = 37  # maximum name length
LENGTH_MAX_NAMESPACE_ID = 19  # maximum namespace length

# namespace version
BLOCKSTACK_VERSION = 1
NAME_SCHEME = MAGIC_BYTES + NAME_REGISTRATION

# burn address for fees (the address of public key
# 0x0000000000000000000000000000000000000000)
BLOCKSTACK_BURN_PUBKEY_HASH = '0000000000000000000000000000000000000000'
BLOCKSTACK_BURN_ADDRESS = virtualchain.hex_hash160_to_address(BLOCKSTACK_BURN_PUBKEY_HASH)   # '1111111111111111111114oLvT2'

# borrowed from Blockstack Core
# never changes, so safe to duplicate to avoid gratuitous imports
MAXIMUM_NAMES_PER_ADDRESS = 25

MAX_RPC_LEN = 1024 * 1024 * 1024

RPC_MAX_ZONEFILE_LEN = 4096     # 4KB
RPC_MAX_PROFILE_LEN = 1024000   # 1MB

CONFIG_FILENAME = 'client.ini'
WALLET_FILENAME = 'wallet.json'

CONFIG_PATH = os.environ.get('BLOCKSTACK_CLIENT_CONFIG')