当前位置: 首页>>代码示例>>Python>>正文


Python pybitcointools.pubkey_to_address函数代码示例

本文整理汇总了Python中pybitcointools.pubkey_to_address函数的典型用法代码示例。如果您正苦于以下问题:Python pubkey_to_address函数的具体用法?Python pubkey_to_address怎么用?Python pubkey_to_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pubkey_to_address函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_pubkey_on_address

def get_pubkey_on_address(public_address):  #only sometimes works
    try:
        txs = get_txs_from_address(public_address)
        found=False
        pubkey=''
        for tx in txs:
            if not found:
                for inp in tx['inputs']:
                    if 'script' in inp:
                        script = inp['script']
                        if len(script)>130:
                            potential_key = script[len(script)-130:len(script)]
                            hashed_key = pybitcointools.pubkey_to_address(potential_key)
                            if hashed_key == public_address:
                                found=True
                                pubkey=potential_key

                            potential_key2= script[len(script)-66:len(script)]
                            #print potential_key2
                            hashed_key2=pybitcointools.pubkey_to_address(potential_key2)
                            if hashed_key2 == public_address:
                                found=True
                                pubkey = potential_key2


        return pubkey, found
    except:
        print "cannot get pubkey on address"
        return '', False
开发者ID:RoPe93,项目名称:bitcrypt,代码行数:29,代码来源:key_scraping.py

示例2: sender_payee_address_from_stealth

def sender_payee_address_from_stealth(sender_prikey, receiver_pubkey):
    # sender - derive payee address
    ss1 = btc.multiply(receiver_pubkey, sender_prikey)
    ss2 = btc.sha256(btc.encode_pubkey((ss1), 'bin_compressed'))
    addr = btc.pubkey_to_address(btc.add_pubkeys(
        receiver_pubkey, btc.privtopub(ss2)))
    return addr
开发者ID:rvaughan,项目名称:Axis-Mundi,代码行数:7,代码来源:btc_utils.py

示例3: create_invoice_user

def create_invoice_user (email):
	BMMySQL().db.ping(True)
	cur = BMMySQL().db.cursor(MySQLdb.cursors.DictCursor)
	cur.execute ("SELECT bm, masterpubkey_btc, offset_btc, feeamount, feecurrency FROM user WHERE email = %s AND active = 1", (email))
	result = False
	for row in cur.fetchall():
		result = row
	if result:
		if result['masterpubkey_btc'][0:4] == "xpub":
			# BIP44
			dpk1 = pybitcointools.bip32_ckd(result['masterpubkey_btc'], 0)
			dpk2 = pybitcointools.bip32_ckd(dpk1, result['offset_btc'])
			pubkey = pybitcointools.bip32_extract_key(dpk2)
		else:
			# Electrum 1.x
			pubkey = pybitcointools.electrum_pubkey(result['masterpubkey_btc'], result['offset_btc'])
		address = pybitcointools.pubkey_to_address(pubkey)
		cur.execute ("UPDATE user SET offset_btc = offset_btc + 1 WHERE email = %s AND active = 1 AND masterpubkey_btc = %s", (email, result['masterpubkey_btc']))
		if result['feecurrency'] in ("USD", "GBP", "EUR"):
			result['feeamount'] /= decimal.Decimal(get_bitcoin_price(result['feecurrency']))
		cur.execute ("INSERT INTO invoice (issuer, address, coin, amount, type, paid) VALUES (%s, %s, 'BTC', %s, 1, 0)", (result['bm'], address, result['feeamount']))
		bitcoind_importaddress(address)
		cur.close()
		return address, result['feeamount'];
	cur.close()
	return False
开发者ID:RoPe93,项目名称:bitmessage-email-gateway,代码行数:26,代码来源:payment.py

示例4: validate_ecdsa

 def validate_ecdsa(self, obfuscated):
   invalid = True
   while invalid:
     ob_randbyte = obfuscated[:-2] + pad(randint(0, 255), 2).upper()
     potential_address = pybitcointools.pubkey_to_address(ob_randbyte)
     if bool(self.rpc_conn.validateaddress(potential_address).isvalid):
       pubkey = ob_randbyte
       invalid = False
   return pubkey
开发者ID:maddenpj,项目名称:omniwallet-tools,代码行数:9,代码来源:tools.py

示例5: __init__

    def __init__(self, private, url=NETVEND_URL, seed=False):
        if seed:
            self._private = pybitcointools.sha256(private)
        else:
            try:
                self._private = pybitcointools.b58check_to_hex(private)
            except AssertionError:
                raise RuntimeError("Invalid private key. Did you mean to set seed=True?")

        self.address = pybitcointools.pubkey_to_address(pybitcointools.privtopub(self._private))
        self.url = url
开发者ID:kewinwang,项目名称:coinflow,代码行数:11,代码来源:netvend.py

示例6: test_stealth_tx_outputs

    def test_stealth_tx_outputs(self):

        nonce = int('deadbeef', 16)
        value = 10**8
        outputs = bc.mk_stealth_tx_outputs(self.addr, value, self.ephem_priv, nonce)

        self.assertEqual(outputs[0]['value'], 0)
        self.assertEqual(outputs[0]['script'], '6a2606deadbeef' + self.ephem_pub)
        self.assertEqual(outputs[1]['address'], bc.pubkey_to_address(self.pay_pub))
        self.assertEqual(outputs[1]['value'], value)
        
        outputs = bc.mk_stealth_tx_outputs(self.testnet_addr, value, self.ephem_priv, nonce, 'testnet')
        
        self.assertEqual(outputs[0]['value'], 0)
        self.assertEqual(outputs[0]['script'], '6a2606deadbeef' + self.ephem_pub)
        self.assertEqual(outputs[1]['address'], bc.pubkey_to_address(self.pay_pub, 111))
        self.assertEqual(outputs[1]['value'], value)

        self.assertRaises(Exception, bc.mk_stealth_tx_outputs, self.testnet_addr, value, self.ephem_priv, nonce, 'btc')
        
        self.assertRaises(Exception, bc.mk_stealth_tx_outputs, self.addr, value, self.ephem_priv, nonce, 'testnet')
开发者ID:cpacia,项目名称:pybitcointools,代码行数:21,代码来源:test_stealth.py

示例7: gen_row

def gen_row(height, file, column_number, column_total, sheet_num, digits):
    rows=number_of_rows()
    keys=GenerateKeys(rows)
    width=width_between_circles()
    f=int2padded_string
    for i in range(rows):
        if True:
#        if i in [0]:
            draw_circle_line(file, keys[i], frame_top()+i*width, frame_side()+height)
            print('Sticker #{} of Row #{} of Sheet #{}.....................Done'.format(f(i + 1, digits), f(column_number + 1, digits), f(sheet_num+1, digits)))
    pubs=[]
    for i in keys:
        pubs.append(pt.pubkey_to_address(i['pub']))
    return pubs
开发者ID:zack-bitcoin,项目名称:bitcoin-stickers,代码行数:14,代码来源:main.py

示例8: generate_tx

def generate_tx(tx_type):

    #update this to support more transactions
    supported_transactions = [50,51,54,55,56,0]

    if tx_type not in supported_transactions:
        return jsonify({ 'status': 400, 'data': 'Unsupported transaction type '+str(tx_type) })
    
    expected_fields=['transaction_version', 'transaction_from','pubkey','fee']

    print "Form ",request.form

    #might add tx 00, 53, etc later;
    if tx_type == 50:
        expected_fields+=['ecosystem', 'property_type', 'previous_property_id', 'property_category', 'property_subcategory', 'property_name', 'property_url', 'property_data', 'number_properties']
    elif tx_type == 51:
        expected_fields+=['ecosystem', 'property_type', 'previous_property_id', 'property_category', 'property_subcategory', 'property_name', 'property_url', 'property_data', 'currency_identifier_desired', 'number_properties', 'deadline', 'earlybird_bonus', 'percentage_for_issuer']
    elif tx_type == 54:
        expected_fields+=['ecosystem', 'property_type', 'previous_property_id', 'property_category', 'property_subcategory', 'property_name', 'property_url', 'property_data']
    elif tx_type == 0:
        expected_fields+=['currency_identifier', 'amount_to_transfer', 'transaction_to']
    elif tx_type in [55,56]:
        expected_fields+=['currency_identifier', 'number_properties']
    for field in expected_fields:
        if field not in request.form:
            return jsonify({ 'status': 403, 'data': 'No field in request form '+field })
        elif request.form[field] == '':
            return jsonify({ 'status': 403, 'data': 'Empty field in request form '+field })

    if 'testnet' in request.form and ( request.form['testnet'] in ['true', 'True'] ):
        global testnet
        testnet =True
        global magicbyte
        magicbyte = 111
        global exodus_address
        exodus_address=testnet_exodus_address

    try:
      if config.D_PUBKEY and ( 'donate' in request.form ) and ( request.form['donate'] in ['true', 'True'] ):
        print "We're Donating to pubkey for: "+pybitcointools.pubkey_to_address(config.D_PUBKEY)
        pubkey = config.D_PUBKEY
      else:
        print "not donating"
        pubkey = request.form['pubkey']
    except NameError, e:
      print e
      pubkey = request.form['pubkey']
开发者ID:Nevtep,项目名称:omniwallet,代码行数:47,代码来源:tx_generate_service.py

示例9: __init__

    def __init__(self, private, url, privtype):
        if privtype is PRIVTYPE_SEED:
            self.private = pybitcointools.sha256(private)
        elif privtype is PRIVTYPE_B58CHECK:
            try:
                self.private = pybitcointools.b58check_to_hex(private)
            except AssertionError:
                raise ValueError("Invalid private key")
        elif privtype is PRIVTYPE_HEX:
            if len(private) == 64:
                self.private = private
            else:
                raise ValueError("Invalid private key")
        else:
            # Raise a ValueError, otherwise self.private would not be defined
            raise ValueError("Invalid privtype")

        self.address = pybitcointools.pubkey_to_address(pybitcointools.privtopub(self.private))
        self.url = url
开发者ID:Syriven,项目名称:py-netvend-proto,代码行数:19,代码来源:netvendtk.py

示例10: __init__

    def __init__(self,tx_type,form):
        self.conn = getRPCconn()
        self.testnet = False
        self.magicbyte = 0
        self.exodus_address=self.mainnet_exodus_address

        if 'testnet' in form and ( form['testnet'] in ['true', 'True'] ):
            self.testnet =True
            self.magicbyte = 111
            self.exodus_address=self.testnet_exodus_address

        try:
          if config.D_PUBKEY and ( 'donate' in form ) and ( form['donate'] in ['true', 'True'] ):
            print "We're Donating to pubkey for: "+pybitcointools.pubkey_to_address(config.D_PUBKEY)
            self.pubkey = config.D_PUBKEY
          else:
            print "not donating"
            self.pubkey = form['pubkey']
        except NameError, e:
          print e
          self.pubkey = form['pubkey']
开发者ID:OmniLayer,项目名称:omniwallet,代码行数:21,代码来源:omnitransaction.py

示例11: create_invoice_domain

def create_invoice_domain (domain, payer):
	BMMySQL().db.ping(True)
	cur = BMMySQL().db.cursor(MySQLdb.cursors.DictCursor)
	filterwarnings('ignore', category = MySQLdb.Warning)
	cur.execute ("SELECT bm, masterpubkey_btc, offset_btc, feeamount, feecurrency FROM domain WHERE name = %s AND active = 1", (domain))
	result = False
	for row in cur.fetchall():
		result = row
	while result:
		if result['masterpubkey_btc'][0:4] == "xpub":
			# BIP44
			dpk1 = pybitcointools.bip32_ckd(result['masterpubkey_btc'], 0)
			dpk2 = pybitcointools.bip32_ckd(dpk1, result['offset_btc'])
			pubkey = pybitcointools.bip32_extract_key(dpk2)
		else:
			# Electrum 1.x
			pubkey = pybitcointools.electrum_pubkey(result['masterpubkey_btc'], result['offset_btc'])
		address = pybitcointools.pubkey_to_address(pubkey)
		cur.execute ("UPDATE domain SET offset_btc = offset_btc + 1 WHERE name = %s AND active = 1 AND masterpubkey_btc = %s", (domain, result['masterpubkey_btc']))
		if result['feecurrency'] in ("USD", "GBP", "EUR"):
			result['feeamount'] /= decimal.Decimal(get_bitcoin_price(result['feecurrency']))
		cur.execute ("INSERT IGNORE INTO invoice (issuer, payer, address, coin, amount, type, paid) VALUES (%s, %s, %s, 'BTC', %s, 0, 0)", (result['bm'], payer, address, result['feeamount']))

		# invoice already exists for that address, increment
		if cur.rowcount == 0:
			cur.execute ("SELECT bm, masterpubkey_btc, offset_btc, feeamount, feecurrency FROM domain WHERE name = %s AND active = 1", (domain))
			result = False
			for row in cur.fetchall():
				result = row
			continue
		
		bitcoind_importaddress(address)
		cur.close()
		return address, result['feeamount'];
	cur.close()
	return False
开发者ID:RoPe93,项目名称:bitmessage-email-gateway,代码行数:36,代码来源:payment.py

示例12: draw_line

def draw_line(filename, nums, x, y):
    num=nums['pub']
    addr=pt.pubkey_to_address(num)
    draw_num(filename, addr[:8], x , y)
开发者ID:zack-bitcoin,项目名称:bitcoin-stickers,代码行数:4,代码来源:main.py

示例13: script_to_destination_address

def script_to_destination_address(script):
    return pybitcointools.pubkey_to_address(script_to_pubkey(script))
开发者ID:RoPe93,项目名称:bitcrypt,代码行数:2,代码来源:util.py

示例14: point_to_address

def point_to_address(pt):
    public_key = point_to_key(pt)
    address = pybitcointools.pubkey_to_address(public_key)
    return address
开发者ID:RoPe93,项目名称:bitcrypt,代码行数:4,代码来源:bitcrypt.py

示例15: build_transaction

def build_transaction(miner_fee_satoshis, pubkey,final_packets, total_packets, total_outs, from_address, to_address=None):
    print 'pubkey', request.form['pubkey'], len(request.form['pubkey']) 
    if len(request.form['pubkey']) < 100:
      print "Compressed Key, using hexspace 21"
      HEXSPACE_FIRST='21'
    else:
      HEXSPACE_FIRST='41'

    #calculate fees
    miner_fee = Decimal(miner_fee_satoshis) / Decimal(1e8)
    if to_address==None or to_address==from_address:
 	    #change goes to sender/receiver
        print "Single extra fee calculation"  
        fee_total = Decimal(miner_fee) + Decimal(0.00005757*total_packets+0.00005757*total_outs) + Decimal(0.00005757)  #exodus output is last
    else:
        #need 1 extra output for exodus and 1 for receiver.
        print "Double extra fee calculation"
        fee_total = Decimal(miner_fee) + Decimal(0.00005757*total_packets+0.00005757*total_outs) + Decimal(2*0.00005757)  #exodus output is last
    fee_total_satoshi = int( round( fee_total * Decimal(1e8) ) )

    #clean sx output, initial version by achamely
    utxo_list = []
    #round so we aren't under fee amount
    dirty_txes = get_utxo( from_address, fee_total_satoshi ).replace(" ", "")

    if (dirty_txes[:3]=='Ass') or (dirty_txes[0][:3]=='Not'):
        raise Exception({ "status": "NOT OK", "error": "Not enough funds, try again. Needed: " + str(fee_total)  })

    for line in dirty_txes.splitlines():
        utxo_list.append(line.split(':'))

    z = 0
    total_amount=0
    unspent_tx = []
    for item in utxo_list:
        # unspent tx: [0] - txid; [1] - vout; [2] - amount;
        if utxo_list[z][0] == "output":
            unspent_tx.append( [ utxo_list[z][1] , utxo_list[z][2] ] )
        if utxo_list[z][0] == "value":
            unspent_tx[-1] += [ int( utxo_list[z][1] ) ]
            total_amount += int( utxo_list[z][1] )
        z += 1

    # calculate change : 
    # (total input amount) - (broadcast fee)
    change = total_amount - fee_total_satoshi

    #DEBUG 
    print [ "Debugging...", dirty_txes,"miner fee sats: ", miner_fee_satoshis,"miner fee: ", miner_fee, "change: ",change,"total_amt: ", total_amount,"fee tot sat: ", fee_total_satoshi,"utxo ",  unspent_tx,"total pax ", total_packets, "total outs ",total_outs,"to ", to_address ]

    #source script is needed to sign on the client credit grazcoin
    hash160=bc_address_to_hash_160(from_address).encode('hex_codec')
    prevout_script='OP_DUP OP_HASH160 ' + hash160 + ' OP_EQUALVERIFY OP_CHECKSIG'

    validnextinputs = []   #get valid redeemable inputs
    for unspent in unspent_tx:
        #retrieve raw transaction to spend it
        prev_tx = getrawtransaction(unspent[0])

        for output in prev_tx.vout:
            if output['scriptPubKey']['reqSigs'] == 1 and output['scriptPubKey']['type'] != 'multisig':
                for address in output['scriptPubKey']['addresses']:
                    if address == from_address and int(output['n']) == int(unspent[1]):
                        validnextinputs.append({ "txid": prev_tx.txid, "vout": output['n']})
                        break

    global exodus_address
    validnextoutputs = { exodus_address: 0.00005757 }
    if to_address != None:
        validnextoutputs[to_address]=0.00005757 #Add for simple send
    
    if change >= 5757: # send anything above dust to yourself
        validnextoutputs[ from_address ] = float( Decimal(change)/Decimal(1e8) )
    
    unsigned_raw_tx = createrawtransaction(validnextinputs, validnextoutputs)
    
    #DEBUG print change,unsigned_raw_tx

    json_tx =  decoderawtransaction(unsigned_raw_tx)
    
    #append  data structure
    ordered_packets = []
    for i in range(total_outs):
        ordered_packets.append([])
    
    #append actual packet
    index = 0
    for i in range(total_outs):
        while len(ordered_packets[i]) < 2 and index != len(final_packets):
            ordered_packets[i].append(final_packets[index])
            index = index + 1
    #DEBUG print ordered_packets
    global magicbyte
    for i in range(total_outs):
        hex_string = "51" + HEXSPACE_FIRST + pubkey
        asm_string = "1 " + pubkey
        addresses = [ pybitcointools.pubkey_to_address(pubkey, magicbyte)]
        n_count = len(validnextoutputs)+i
        total_sig_count = 1
        #DEBUG print [i,'added string', ordered_packets[i]]
#.........这里部分代码省略.........
开发者ID:Zifare,项目名称:omniwallet,代码行数:101,代码来源:txtools.py


注:本文中的pybitcointools.pubkey_to_address函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。