Esempio n. 1
0
import pybitcoin
from pybitcoin import embed_data_in_blockchain, \
    analyze_private_key, serialize_sign_and_broadcast, make_op_return_script, \
    make_pay_to_address_script, b58check_encode, b58check_decode, serialize_transaction, get_unspents

 
from pybitcoin.transactions.outputs import calculate_change_amount
from utilitybelt import is_hex
from binascii import hexlify, unhexlify

from ..b40 import b40_to_hex, bin_to_b40, is_b40
from ..config import *
from ..scripts import *

import virtualchain
log = virtualchain.get_logger("blockstack-client")


def build(name):
    """
    Takes in a name to import.  Name must include the namespace ID.
    
    Record format:
    
    0    2  3                             39
    |----|--|-----------------------------|
    magic op   name.ns_id (37 bytes)
    
    The transaction itself will have two outputs:
    * the recipient
    * the hash of the name's associated data
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with Blockstack. If not, see <http://www.gnu.org/licenses/>.
"""

from ..config import *
from ..hashing import *
from ..scripts import *
from ..nameset import *
from binascii import hexlify, unhexlify

import blockstack_client
from blockstack_client.operations import *

import virtualchain
log = virtualchain.get_logger("blockstack-server")

# consensus hash fields (ORDER MATTERS!)
FIELDS = NAMEREC_FIELDS + [
    'sender',     # scriptPubKey hex script that identifies the principal to own this name
    'address'     # principal's address from the scriptPubKey in the transaction
]

# fields this operation changes
REGISTER_MUTATE_FIELDS = NAMEREC_MUTATE_FIELDS + [
    'last_renewed',
    'first_registered',
    'revoked',
    'sender',
    'address',
    'sender_pubkey',
Esempio n. 3
0
    analyze_private_key, serialize_sign_and_broadcast, make_op_return_script, get_unspents, \
    make_pay_to_address_script, b58check_encode, b58check_decode, BlockchainInfoClient, hex_hash160

from pybitcoin.transactions.outputs import calculate_change_amount

from utilitybelt import is_hex
from binascii import hexlify, unhexlify
import types
import json

from ..b40 import b40_to_hex, bin_to_b40, is_b40
from ..config import *
from ..scripts import blockstack_script_to_hex, add_magic_bytes, hash_name, is_namespace_valid
   
import virtualchain
log = virtualchain.get_logger("blockstack-log")


def serialize_int( int_field, numbytes ):
   """
   Serialize an integer to a hex string that is padlen characters long.
   Raise an exception on overflow.
   """
   
   if int_field >= 2**(numbytes*8) or int_field < -(2**(numbytes*8)):
      raise Exception("Integer overflow (%s bytes)" % (numbytes) )
   
   format_str = "%%0.%sx" % (numbytes*2) 
   hex_str = format_str % int_field 
   
   if len(hex_str) % 2 != 0:
import sys

from blockstack.lib import *
import hashlib
import binascii

import mock_bitcoind

import virtualchain 

""""
Mock UTXO provider.
"""

mock_utxo_client = None
log = virtualchain.get_logger("mock_utxo_provider")

class MockUTXOProvider(object):

    def __init__(self, bitcoind ):
        
        self.unspents = {}  # map address to unspent outputs
        self.tx_addrs = {}  # map txid to list of addresses
        self.bitcoind = bitcoind

        # crawl blocks and build up utxo set 
        for i in xrange( bitcoind.getstartblock(), bitcoind.getblockcount()+1 ):
            block_hash = bitcoind.getblockhash( i )
            block = bitcoind.getblock( block_hash )
            txids = block['tx']
            txs = [bitcoind.getrawtransaction( txid, 0 ) for txid in txids]
  "facebook": {
    "username": "******", 
    "proof": {
      "url": "https://facebook.com/sunspider/posts/674912239245011"
    }
  }
}

dataset_change = "This is the mutated dataset"

zonefile_hash = None
zonefile_hash_2 = None
immutable_hash = None
datastore_name = None

log = virtualchain.get_logger("name_preorder_register_update_blockstackurl_nodatakey")

def scenario( wallets, **kw ):

    global put_result, wallet_keys, legacy_profile, zonefile_hash, zonefile_hash_2, immutable_hash, datastore_name

    wallet_keys = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[8].privkey, wallets[3].privkey, None )
    wallet_keys_2 = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[9].privkey, wallets[6].privkey, None  )

    test_proxy = testlib.TestAPIProxy()
    blockstack_client.set_default_proxy( test_proxy )

    testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with Blockstack. If not, see <http://www.gnu.org/licenses/>.
"""

from ..config import *
from ..hashing import *
from ..scripts import *
from ..nameset import *

from binascii import hexlify, unhexlify

import json

import virtualchain
log = virtualchain.get_logger("blockstack-server")

# consensus hash fields (ORDER MATTERS!)
FIELDS = [
    'namespace_id',  # human-readable namespace ID
    'preorder_hash',  # hash(namespace_id,sender,reveal_addr) from the preorder (binds this namespace to its preorder)
    'version',  # namespace rules version
    'sender',  # the scriptPubKey hex script that identifies the preorderer
    'sender_pubkey',  # if sender is a p2pkh script, this is the public key
    'address',  # address of the sender, from the scriptPubKey
    'recipient',  # the scriptPubKey hex script that identifies the revealer.
    'recipient_address',  # the address of the revealer
    'block_number',  # block number at which this namespace was preordered
    'reveal_block',  # block number at which this namespace was revealed
    'op',  # byte code identifying this operation to Blockstack
    'txid',  # transaction ID at which this namespace was revealed
Esempio n. 7
0
import pybitcoin 
import traceback
import json
import threading
import copy

from .namedb import BlockstackDB

from ..config import *
from ..operations import parse_preorder, parse_registration, parse_update, parse_transfer, parse_revoke, \
    parse_name_import, parse_namespace_preorder, parse_namespace_reveal, parse_namespace_ready, parse_announce, \
    get_transfer_recipient_from_outputs, get_import_update_hash_from_outputs, get_registration_recipient_from_outputs, \
    SERIALIZE_FIELDS

import virtualchain
log = virtualchain.get_logger("blockstack-log")

blockstack_db = None
last_load_time = 0
last_check_time = 0
reload_lock = threading.Lock()

def get_burn_fee_from_outputs( outputs ):
    """
    Given the set of outputs, find the fee sent 
    to our burn address.
    
    Return the fee on success
    Return None if not found
    """
    
    (at your option) any later version.

    Blockstack is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with Blockstack. If not, see <http://www.gnu.org/licenses/>.
"""

import testlib
import virtualchain
import blockstack
import json

log = virtualchain.get_logger('name_pre_reg_multi_snv')

wallets = [
    testlib.Wallet("5JesPiN68qt44Hc2nT8qmyZ1JDwHebfoh9KQ52Lazb1m1LaKNj9",
                   100000000000),
    testlib.Wallet("5KHqsiU9qa77frZb6hQy9ocV7Sus9RWJcQGYYBJJBb2Efj1o77e",
                   100000000000),
    testlib.Wallet("5Kg5kJbQHvk1B64rJniEmgbD83FpZpbw2RjdAZEzTefs9ihN3Bz",
                   100000000000),
    testlib.Wallet("5JuVsoS9NauksSkqEjbUZxWwgGDQbMwPsEfoRBSpLpgDX1RtLX7",
                   100000000000),
    testlib.Wallet("5KEpiSRr1BrT8vRD7LKGCEmudokTh1iMHbiThMQpLdwBwhDJB1T",
                   100000000000),
    testlib.Wallet("5K5hDuynZ6EQrZ4efrchCwy6DLhdsEzuJtTDAf3hqdsCKbxfoeD",
                   100000000000),
    testlib.Wallet("5J39aXEeHh9LwfQ4Gy5Vieo7sbqiUMBXkPH7SaMHixJhSSBpAqz",
Esempio n. 9
0
def get_logger( debug=DEBUG ):
    logger = virtualchain.get_logger("blockstack-client")
    logger.setLevel(logging.DEBUG if debug else logging.INFO)
    return logger