Example #1
0
def broadcast( namespace_id, reveal_addr, lifetime, coeff, base_cost, bucket_exponents, nonalpha_discount, no_vowel_discount, private_key, blockchain_client, testset=False ):
   """
   Propagate a namespace.
   
   Arguments:
   namespace_id         human-readable (i.e. base-40) name of the namespace
   reveal_addr          address to own this namespace until it is ready
   lifetime:            the number of blocks for which names will be valid (pass a negative value for "infinite")
   coeff:               cost multipler
   base_cost:           the base cost (i.e. cost of a 1-character name), in satoshis 
   bucket_exponents:    bucket cost exponents to which to raise the base cost 
   nonalpha_discount:   discount multipler for non-alpha-character names 
   no_vowel_discount:   discount multipler for no-vowel names
   """
   
   nulldata = build( namespace_id, BLOCKSTORE_VERSION, reveal_addr, lifetime, coeff, base_cost, bucket_exponents, nonalpha_discount, no_vowel_discount, testset=testset )
   
   # get inputs and from address
   private_key_obj, from_address, inputs = analyze_private_key(private_key, blockchain_client)
    
   # build custom outputs here
   outputs = make_outputs(nulldata, inputs, reveal_addr, from_address, format='hex')
    
   # serialize, sign, and broadcast the tx
   response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj, blockchain_client)
    
   # response = {'success': True }
   response.update({'data': nulldata})
    
   return response
def broadcast(name, recipient_address, update_hash, private_key, blockchain_client, blockchain_broadcaster=None, tx_only=False, testset=False):
   
    if blockchain_broadcaster is None:
        blockchain_broadcaster = blockchain_client 
    
    nulldata = build(name, testset=testset)
    
    # convert update_hash from a hex string so it looks like an address
    update_hash_b58 = b58check_encode( unhexlify(update_hash) )
    
    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(private_key, blockchain_client)
    
    # NAME_IMPORT outputs
    outputs = make_outputs(nulldata, inputs, recipient_address, from_address, update_hash_b58, format='hex')
    
    if tx_only:
        
        unsigned_tx = serialize_transaction( inputs, outputs )
        return {"unsigned_tx": unsigned_tx}
    
    else:
        # serialize, sign, and broadcast the tx
        response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj, blockchain_broadcaster)
        
        # response = {'success': True }
        response.update({'data': nulldata})
        
        # return the response
        return response
Example #3
0
def broadcast(name,
              destination_address,
              keepdata,
              consensus_hash,
              private_key,
              blockchain_client,
              testset=False):

    nulldata = build(name, keepdata, consensus_hash, testset=testset)

    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(
        private_key, blockchain_client)

    # build custom outputs here
    outputs = make_outputs(nulldata,
                           inputs,
                           destination_address,
                           from_address,
                           format='hex')

    # serialize, sign, and broadcast the tx
    response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj,
                                            blockchain_client)

    # response = {'success': True }
    response.update({'data': nulldata})

    # return the response
    return response
Example #4
0
def broadcast(name,
              recipient_address,
              update_hash,
              private_key,
              blockchain_client,
              testset=False):

    nulldata = build(name, testset=testset)

    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(
        private_key, blockchain_client)

    # convert update_hash from a hex string so it looks like an address
    update_hash_b58 = b58check_encode(unhexlify(update_hash))

    # build custom outputs here
    outputs = make_outputs(nulldata,
                           inputs,
                           recipient_address,
                           from_address,
                           update_hash_b58,
                           format='hex')

    # serialize, sign, and broadcast the tx
    response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj,
                                            blockchain_client)

    # response = {'success': True }
    response.update({'data': nulldata})

    # return the response
    return response
Example #5
0
def broadcast(name, recipient_address, update_hash, private_key, blockchain_client, blockchain_broadcaster=None, tx_only=False, testset=False):
   
    if blockchain_broadcaster is None:
        blockchain_broadcaster = blockchain_client 
    
    nulldata = build(name, testset=testset)
    
    # convert update_hash from a hex string so it looks like an address
    update_hash_b58 = b58check_encode( unhexlify(update_hash) )
    
    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(private_key, blockchain_client)
    
    # NAME_IMPORT outputs
    outputs = make_outputs(nulldata, inputs, recipient_address, from_address, update_hash_b58, format='hex')
    
    if tx_only:
        
        unsigned_tx = serialize_transaction( inputs, outputs )
        return {"unsigned_tx": unsigned_tx}
    
    else:
        # serialize, sign, and broadcast the tx
        response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj, blockchain_broadcaster)
        
        # response = {'success': True }
        response.update({'data': nulldata})
        
        # return the response
        return response
Example #6
0
def broadcast(name,
              register_addr,
              consensus_hash,
              private_key,
              blockchain_client,
              fee,
              testset=False):
    """
    Builds and broadcasts a preorder transaction.
    """

    script_pubkey = get_script_pubkey(private_key)

    nulldata = build(name,
                     script_pubkey,
                     register_addr,
                     consensus_hash,
                     testset=testset)

    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(
        private_key, blockchain_client)

    # build custom outputs here
    outputs = make_outputs(nulldata, inputs, from_address, fee, format='hex')

    # serialize, sign, and broadcast the tx
    response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj,
                                            blockchain_client)

    # response = {'success': True }
    response.update({'data': nulldata})

    return response
def broadcast( namespace_id, register_addr, consensus_hash, private_key, blockchain_client, fee, testset=False ):
   """
   Propagate a namespace.
   
   Arguments:
   namespace_id         human-readable (i.e. base-40) name of the namespace
   register_addr        the addr of the key that will reveal the namespace (mixed into the preorder to prevent name preimage attack races)
   private_key          the Bitcoin address that created this namespace, and can populate it.
   """
    
   script_pubkey = get_script_pubkey( private_key )
   nulldata = build( namespace_id, script_pubkey, register_addr, consensus_hash, testset=testset )
   
   # get inputs and from address
   private_key_obj, from_address, inputs = analyze_private_key(private_key, blockchain_client)
    
   # build custom outputs here
   outputs = make_outputs(nulldata, inputs, from_address, fee, format='hex')
    
   # serialize, sign, and broadcast the tx
   response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj, blockchain_client)
    
   # response = {'success': True }
   response.update({'data': nulldata})
    
   return response
Example #8
0
def broadcast(name,
              register_addr,
              private_key,
              blockchain_client,
              renewal_fee=None,
              testset=False):

    nulldata = build(name, testset=testset)

    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(
        private_key, blockchain_client)

    # build custom outputs here
    outputs = make_outputs(nulldata,
                           inputs,
                           register_addr,
                           from_address,
                           renewal_fee=renewal_fee,
                           format='hex')

    # serialize, sign, and broadcast the tx
    response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj,
                                            blockchain_client)

    # response = {'success': True }
    response.update({'data': nulldata})

    return response
Example #9
0
def broadcast(name, private_key, register_addr, blockchain_client, renewal_fee=None, blockchain_broadcaster=None, tx_only=False, user_public_key=None, subsidy_public_key=None, testset=False):
    
    # sanity check 
    if subsidy_public_key is not None:
        # if subsidizing, we're only giving back a tx to be signed
        tx_only = True

    if subsidy_public_key is None and private_key is None:
        raise Exception("Missing both public and private key")
    
    if not tx_only and private_key is None:
        raise Exception("Need private key for broadcasting")
    
    if blockchain_broadcaster is None:
        blockchain_broadcaster = blockchain_client 
    
    from_address = None 
    change_inputs = None
    private_key_obj = None
    subsidized_renewal = False
    
    if subsidy_public_key is not None:
        # subsidizing
        pubk = BitcoinPublicKey( subsidy_public_key )
        
        if user_public_key is not None and renewal_fee is not None:
            # renewing, and subsidizing the renewal
            from_address = BitcoinPublicKey( user_public_key ).address() 
            subsidized_renewal = True

        else:
            # registering or renewing under the subsidy key
            from_address = pubk.address()

        change_inputs = get_unspents( from_address, blockchain_client )

    elif private_key is not None:
        # ordering directly
        pubk = BitcoinPrivateKey( private_key ).public_key()
        public_key = pubk.to_hex()
        
        # get inputs and from address using private key
        private_key_obj, from_address, change_inputs = analyze_private_key(private_key, blockchain_client)
        
    nulldata = build(name, testset=testset)
    outputs = make_outputs(nulldata, change_inputs, register_addr, from_address, renewal_fee=renewal_fee, pay_fee=(not subsidized_renewal), format='hex')
   
    if tx_only:
        
        unsigned_tx = serialize_transaction( change_inputs, outputs )
        return {"unsigned_tx": unsigned_tx}
    
    else:
        
        # serialize, sign, and broadcast the tx
        response = serialize_sign_and_broadcast(change_inputs, outputs, private_key_obj, blockchain_broadcaster)
        response.update({'data': nulldata})
        return response
Example #10
0
def broadcast(name_list, private_key, register_addr_list, consensus_hash, blockchain_client, fee, \
              blockchain_broadcaster=None, subsidy_public_key=None, tx_only=False, testset=False):
    """
    Builds and broadcasts a preorder transaction.

    @subsidy_public_key: if given, the public part of the subsidy key 
    """

    if subsidy_public_key is not None:
        # subsidizing, and only want the tx 
        tx_only = True
    
    # sanity check 
    if subsidy_public_key is None and private_key is None:
        raise Exception("Missing both client public and private key")
    
    if blockchain_broadcaster is None:
        blockchain_broadcaster = blockchain_client 

    from_address = None     # change address
    inputs = None
    private_key_obj = None
    script_pubkey = None    # to be mixed into preorder hash
    
    if subsidy_public_key is not None:
        # subsidizing
        pubk = BitcoinPublicKey( subsidy_public_key )
        
        from_address = BitcoinPublicKey( subsidy_public_key ).address()

        inputs = get_unspents( from_address, blockchain_client )
        script_pubkey = get_script_pubkey( subsidy_public_key )

    else:
        # ordering directly
        pubk = BitcoinPrivateKey( private_key ).public_key()
        public_key = pubk.to_hex()
        script_pubkey = get_script_pubkey( public_key )
        
        # get inputs and from address using private key
        private_key_obj, from_address, inputs = analyze_private_key(private_key, blockchain_client)
        
    nulldata = build( name_list, script_pubkey, register_addr_list, consensus_hash, testset=testset)
    outputs = make_outputs(nulldata, inputs, from_address, fee, format='hex')
    
    if tx_only:

        unsigned_tx = serialize_transaction( inputs, outputs )
        return {"unsigned_tx": unsigned_tx}
    
    else:
        # serialize, sign, and broadcast the tx
        response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj, blockchain_client)
        response.update({'data': nulldata})
        return response
Example #11
0
def broadcast(namespace_id,
              reveal_addr,
              lifetime,
              coeff,
              base_cost,
              bucket_exponents,
              nonalpha_discount,
              no_vowel_discount,
              private_key,
              blockchain_client,
              testset=False):
    """
   Propagate a namespace.
   
   Arguments:
   namespace_id         human-readable (i.e. base-40) name of the namespace
   reveal_addr          address to own this namespace until it is ready
   lifetime:            the number of blocks for which names will be valid (pass a negative value for "infinite")
   coeff:               cost multipler
   base_cost:           the base cost (i.e. cost of a 1-character name), in satoshis 
   bucket_exponents:    bucket cost exponents to which to raise the base cost 
   nonalpha_discount:   discount multipler for non-alpha-character names 
   no_vowel_discount:   discount multipler for no-vowel names
   """

    nulldata = build(namespace_id,
                     BLOCKSTORE_VERSION,
                     reveal_addr,
                     lifetime,
                     coeff,
                     base_cost,
                     bucket_exponents,
                     nonalpha_discount,
                     no_vowel_discount,
                     testset=testset)

    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(
        private_key, blockchain_client)

    # build custom outputs here
    outputs = make_outputs(nulldata,
                           inputs,
                           reveal_addr,
                           from_address,
                           format='hex')

    # serialize, sign, and broadcast the tx
    response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj,
                                            blockchain_client)

    # response = {'success': True }
    response.update({'data': nulldata})

    return response
Example #12
0
def broadcast(namespace_id,
              register_addr,
              consensus_hash,
              private_key,
              blockchain_client,
              fee,
              pay_fee=True,
              tx_only=False,
              testset=False,
              blockchain_broadcaster=None):
    """
   Propagate a namespace.
   
   Arguments:
   namespace_id         human-readable (i.e. base-40) name of the namespace
   register_addr        the addr of the key that will reveal the namespace (mixed into the preorder to prevent name preimage attack races)
   private_key          the Bitcoin address that created this namespace, and can populate it.
   """

    if blockchain_broadcaster is None:
        blockchain_broadcaster = blockchain_client

    pubkey_hex = BitcoinPrivateKey(private_key).public_key().to_hex()

    script_pubkey = get_script_pubkey(pubkey_hex)
    nulldata = build(namespace_id,
                     script_pubkey,
                     register_addr,
                     consensus_hash,
                     testset=testset)

    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(
        private_key, blockchain_client)

    # build custom outputs here
    outputs = make_outputs(nulldata, inputs, from_address, fee, format='hex')

    if tx_only:

        unsigned_tx = serialize_transaction(inputs, outputs)
        return {"unsigned_tx": unsigned_tx}

    else:
        # serialize, sign, and broadcast the tx
        response = serialize_sign_and_broadcast(inputs, outputs,
                                                private_key_obj,
                                                blockchain_broadcaster)

        # response = {'success': True }
        response.update({'data': nulldata})

        return response
Example #13
0
def broadcast(name, private_key, register_addr, consensus_hash, blockchain_client, fee, blockchain_broadcaster=None, tx_only=False, pay_fee=True, public_key=None, testset=False):
    """
    Builds and broadcasts a preorder transaction.
    """
    
    # sanity check 
    if public_key is None and private_key is None:
        raise Exception("Missing both public and private key")
    
    if not tx_only and private_key is None:
        raise Exception("Need private key for broadcasting")
    
    if blockchain_broadcaster is None:
        blockchain_broadcaster = blockchain_client 
    
    from_address = None 
    inputs = None
    private_key_obj = None
    
    if private_key is not None:
        # ordering directly 
        pubk = BitcoinPrivateKey( private_key ).public_key()
        public_key = pubk.to_hex()
        
        # get inputs and from address using private key
        private_key_obj, from_address, inputs = analyze_private_key(private_key, blockchain_client)
        
    elif public_key is not None:
        # subsidizing 
        pubk = BitcoinPublicKey( public_key )
        from_address = pubk.address()
        
        # get inputs from utxo provider 
        inputs = get_unspents( from_address, blockchain_client )
        
    script_pubkey = get_script_pubkey( public_key )
    nulldata = build( name, script_pubkey, register_addr, consensus_hash, testset=testset)
    
    # build custom outputs here
    outputs = make_outputs(nulldata, inputs, from_address, fee, pay_fee=pay_fee, format='hex')
    
    if tx_only:
        unsigned_tx = serialize_transaction( inputs, outputs )
        return {"unsigned_tx": unsigned_tx}
    
    else:
        # serialize, sign, and broadcast the tx
        response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj, blockchain_client)
        response.update({'data': nulldata})
        return response
def broadcast(
    namespace_id,
    register_addr,
    consensus_hash,
    private_key,
    blockchain_client,
    fee,
    pay_fee=True,
    tx_only=False,
    testset=False,
    blockchain_broadcaster=None,
):
    """
   Propagate a namespace.
   
   Arguments:
   namespace_id         human-readable (i.e. base-40) name of the namespace
   register_addr        the addr of the key that will reveal the namespace (mixed into the preorder to prevent name preimage attack races)
   private_key          the Bitcoin address that created this namespace, and can populate it.
   """

    if blockchain_broadcaster is None:
        blockchain_broadcaster = blockchain_client

    pubkey_hex = BitcoinPrivateKey(private_key).public_key().to_hex()

    script_pubkey = get_script_pubkey(pubkey_hex)
    nulldata = build(namespace_id, script_pubkey, register_addr, consensus_hash, testset=testset)

    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(private_key, blockchain_client)

    # build custom outputs here
    outputs = make_outputs(nulldata, inputs, from_address, fee, format="hex")

    if tx_only:

        unsigned_tx = serialize_transaction(inputs, outputs)
        return {"unsigned_tx": unsigned_tx}

    else:
        # serialize, sign, and broadcast the tx
        response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj, blockchain_broadcaster)

        # response = {'success': True }
        response.update({"data": nulldata})

        return response
Example #15
0
def broadcast(name, register_addr, private_key, blockchain_client, renewal_fee=None, testset=False):
    
    nulldata = build(name, testset=testset)
    
    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(private_key, blockchain_client)
    
    # build custom outputs here
    outputs = make_outputs(nulldata, inputs, register_addr, from_address, renewal_fee=renewal_fee, format='hex')
    
    # serialize, sign, and broadcast the tx
    response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj, blockchain_client)
    
    # response = {'success': True }
    response.update({'data': nulldata})
    
    return response
Example #16
0
def broadcast(name, destination_address, keepdata, consensus_hash, private_key, blockchain_client, testset=False):
   
    nulldata = build(name, keepdata, consensus_hash, testset=testset)
    
    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(private_key, blockchain_client)
    
    # build custom outputs here
    outputs = make_outputs(nulldata, inputs, destination_address, from_address, format='hex')
    
    # serialize, sign, and broadcast the tx
    response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj, blockchain_client)
    
    # response = {'success': True }
    response.update({'data': nulldata})
    
    # return the response
    return response
Example #17
0
def broadcast(name, recipient_address, update_hash, private_key, blockchain_client, testset=False):
   
    nulldata = build(name, testset=testset)
    
    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(private_key, blockchain_client)
    
    # convert update_hash from a hex string so it looks like an address
    update_hash_b58 = b58check_encode( unhexlify(update_hash) )
    
    # build custom outputs here
    outputs = make_outputs(nulldata, inputs, recipient_address, from_address, update_hash_b58, format='hex')
    
    # serialize, sign, and broadcast the tx
    response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj, blockchain_client)
    
    # response = {'success': True }
    response.update({'data': nulldata})
    
    # return the response
    return response
Example #18
0
def broadcast(name, register_addr, consensus_hash, private_key, blockchain_client, fee, testset=False):
    """
    Builds and broadcasts a preorder transaction.
    """
    
    script_pubkey = get_script_pubkey( private_key )
    
    nulldata = build( name, script_pubkey, register_addr, consensus_hash, testset=testset)
    
    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(private_key, blockchain_client)
    
    # build custom outputs here
    outputs = make_outputs(nulldata, inputs, from_address, fee, format='hex')
    
    # serialize, sign, and broadcast the tx
    response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj, blockchain_client)
    
    # response = {'success': True }
    response.update({'data': nulldata})
    
    return response
Example #19
0
def broadcast(namespace_id,
              register_addr,
              consensus_hash,
              private_key,
              blockchain_client,
              fee,
              testset=False):
    """
   Propagate a namespace.
   
   Arguments:
   namespace_id         human-readable (i.e. base-40) name of the namespace
   register_addr        the addr of the key that will reveal the namespace (mixed into the preorder to prevent name preimage attack races)
   private_key          the Bitcoin address that created this namespace, and can populate it.
   """

    script_pubkey = get_script_pubkey(private_key)
    nulldata = build(namespace_id,
                     script_pubkey,
                     register_addr,
                     consensus_hash,
                     testset=testset)

    # get inputs and from address
    private_key_obj, from_address, inputs = analyze_private_key(
        private_key, blockchain_client)

    # build custom outputs here
    outputs = make_outputs(nulldata, inputs, from_address, fee, format='hex')

    # serialize, sign, and broadcast the tx
    response = serialize_sign_and_broadcast(inputs, outputs, private_key_obj,
                                            blockchain_client)

    # response = {'success': True }
    response.update({'data': nulldata})

    return response
Example #20
0
def broadcast(name,
              destination_address,
              keepdata,
              consensus_hash,
              private_key,
              blockchain_client,
              blockchain_broadcaster=None,
              tx_only=False,
              user_public_key=None,
              testset=False):

    # sanity check
    pay_fee = True
    if user_public_key is not None:
        pay_fee = False
        tx_only = True

    if user_public_key is None and private_key is None:
        raise Exception("Missing both public and private key")

    if not tx_only and private_key is None:
        raise Exception("Need private key for broadcasting")

    if blockchain_broadcaster is None:
        blockchain_broadcaster = blockchain_client

    from_address = None
    inputs = None
    private_key_obj = None

    if user_public_key is not None:
        # subsidizing
        pubk = BitcoinPublicKey(user_public_key)

        from_address = pubk.address()
        inputs = get_unspents(from_address, blockchain_client)

    elif private_key is not None:
        # ordering directly
        pubk = BitcoinPrivateKey(private_key).public_key()
        public_key = pubk.to_hex()

        # get inputs and from address using private key
        private_key_obj, from_address, inputs = analyze_private_key(
            private_key, blockchain_client)

    nulldata = build(name, keepdata, consensus_hash, testset=testset)
    outputs = make_outputs(nulldata,
                           inputs,
                           destination_address,
                           from_address,
                           pay_fee=pay_fee,
                           format='hex')

    if tx_only:

        unsigned_tx = serialize_transaction(inputs, outputs)
        return {"unsigned_tx": unsigned_tx}

    else:
        # serialize, sign, and broadcast the tx
        response = serialize_sign_and_broadcast(inputs, outputs,
                                                private_key_obj,
                                                blockchain_broadcaster)
        response.update({'data': nulldata})
        return response