本文整理汇总了Python中tools.make_address函数的典型用法代码示例。如果您正苦于以下问题:Python make_address函数的具体用法?Python make_address怎么用?Python make_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_address函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: home
def home(DB, dic):
if 'BrainWallet' in dic:
dic['privkey']=tools.det_hash(dic['BrainWallet'])
elif 'privkey' not in dic:
return "<p>You didn't type in your brain wallet.</p>"
privkey=dic['privkey']
pubkey=tools.privtopub(dic['privkey'])
address=tools.make_address([pubkey], 1)
if 'do' in dic.keys():
if dic['do']=='spend':
spend(float(dic['amount']), pubkey, privkey, dic['to'], DB)
out=empty_page
out=out.format('<p>your address: ' +str(address)+'</p>{}')
out=out.format('<p>current block: ' +str(DB['length'])+'</p>{}')
balance=blockchain.db_get(address, DB)['amount']
for tx in DB['txs']:
if tx['type'] == 'spend' and tx['to'] == address:
balance += tx['amount'] - custom.fee
if tx['type'] == 'spend' and tx['pubkeys'][0] == pubkey:
balance -= tx['amount']
out=out.format('<p>current balance is: ' +str(balance/100000.0)+'</p>{}')
if balance>0:
out=out.format(easyForm('/home', 'spend money', '''
<input type="hidden" name="do" value="spend">
<input type="text" name="to" value="address to give to">
<input type="text" name="amount" value="amount to spend">
<input type="hidden" name="privkey" value="{}">'''.format(privkey)))
txt=''' <input type="hidden" name="privkey" value="{}">'''
s=easyForm('/home', 'Refresh', txt.format(privkey))
return out.format(s)
开发者ID:Noelkd,项目名称:basiccoin,代码行数:30,代码来源:gui.py
示例2: add_tx
def add_tx(tx, DB):
# Attempt to add a new transaction into the pool.
address = tools.make_address(tx['pubkeys'], len(tx['signatures']))
def verify_count(tx, txs):
return tx['count'] != count(address, DB)
def type_check(tx, txs):
if 'type' not in tx:
return True
if tx['type'] == 'mint':
return True
return tx['type'] not in transactions.tx_check
def too_big_block(tx, txs):
return len(tools.package(txs+[tx])) > networking.MAX_MESSAGE_SIZE - 5000
def verify_tx(tx, txs):
if type_check(tx, txs):
return False
if tx in txs:
return False
if verify_count(tx, txs):
return False
if too_big_block(tx, txs):
return False
return transactions.tx_check[tx['type']](tx, txs, DB)
if verify_tx(tx, DB['txs']):
DB['txs'].append(tx)
开发者ID:tubaman,项目名称:basiccoin,代码行数:30,代码来源:blockchain.py
示例3: add_tx
def add_tx(tx, DB):
#Attempt to add a new transaction into the pool.
address=tools.make_address(tx['id'], len(tx['signature']))
#print('address: ' +str(address))
#if address in ['01907260ccad051d995b3566307b7b785b0ef04664ab027e8ad2a037c1522693',0x01907260ccad051d995b3566307b7b785b0ef04664ab027e8ad2a037c1522693]: error('here')
#print('tx: ' +str(tx))
def verify_count(tx, txs): return tx['count']!=count(address, DB)
def tx_type_check(tx, txs): return type(tx) != type({'a':1})
def type_check(tx, txs):
return 'type' not in tx or tx['type'] not in transactions.tx_check
def too_big_block(tx, txs):
return len(tools.package(txs+[tx]))>networking.MAX_MESSAGE_SIZE-5000
def verify_tx(tx, txs):
if type_check(tx, txs): return False
if verify_count(tx, txs): return False
if too_big_block(tx, txs): return False
if 'start' in tx and DB['length']<tx['start']: return False
if 'end' in tx and DB['length']>tx['end']: return False
#print('tx to transcations: ' +str(tx))
return transactions.tx_check[tx['type']](tx, txs, DB)
if verify_tx(tx, DB['txs']): DB['txs'].append(tx)
开发者ID:andradeandrey,项目名称:basiccoin,代码行数:27,代码来源:blockchain.py
示例4: main
def main(c=0):
if type(c)==int:
p={'command':sys.argv[1:]}
else:
p={'command':c}
if len(p['command'])==0:
p['command'].append(' ')
c=p['command']
if c[0]=='make_PM':
tx=build_pm()
return run_command({'command':['pushtx', tools.package(tx).encode('base64')]})
elif c[0]=='buy_shares':
tx=build_buy_shares()
return run_command({'command':['pushtx', tools.package(tx).encode('base64')]})
elif c[0]=='start':
r=connect({'command':'blockcount'})
if is_off(r):
p=raw_input('what is your password?\n')
daemonize(lambda: threads.main(p))
else:
print('blockchain is already running')
elif c[0]=='new_address':
if len(c)<2:
print('what is your brain wallet? not enough inputs.')
else:
privkey=tools.det_hash(c[1])
pubkey=tools.privtopub(privkey)
address=tools.make_address([pubkey], 1)
return({'brain':str(c[1]),
'privkey':str(privkey),
'pubkey':str(pubkey),
'address':str(address)})
else:
return run_command(p)
开发者ID:BumblebeeBat,项目名称:FlyingFox,代码行数:34,代码来源:cli.py
示例5: build_pm
def build_pm():
tx={'type':'prediction_market', 'fees':0}
pubkey=str(raw_input('What is the address or pubkey of the owner of the PM?\n>'))
if len(pubkey)>40:
tx['owner']=tools.make_address([pubkey], 1)
else:
tx['owner']=pubkey
tx['PM_id']=str(raw_input('What is the unique name for this new prediction market?\n>'))
tx['B']=int(raw_input('how big should B be? Initial investment is B*ln(n) where n is the number of states\n>'))
num_decisions=int(raw_input('how many decisions is this prediction market to be based upon?\n>'))
tx['decisions']=[]
for i in range(num_decisions):
tx['decisions'].append(str(raw_input('What is the unique name of the '+str(i)+' decision?\n>')))
num_states=int(raw_input('how many states can this PM result in?\n>'))
if num_states>2**num_decisions:
print('too many states')
return False
tx['states_combinatory']=[]
tx['states']=[]
for i in range(num_states):
tx['states'].append(str(raw_input('what is the text title of the '+str(i)+' state?\n>')))
if i!=num_states-1:
next_comb=(str(raw_input('how does the '+str(i)+' state depend upon the outcome of the decisions? For example: if there are 2 decisions, and this market only comes true when the first is "yes" and the second is "no", then you would put: "1 0" here.\n>')))
tx['states_combinatory'].append(map(int, next_comb.split(' ')))
return tx
开发者ID:truthcoin,项目名称:skunkworks,代码行数:25,代码来源:truth_cli.py
示例6: easy_add_transaction
def easy_add_transaction(tx_orig, privkey='default'):
tx = copy.deepcopy(tx_orig)
if privkey in ['default', 'Default']:
if tools.db_existence('privkey'):
privkey = tools.db_get('privkey')
else:
return 'No private key is known, so the tx cannot be signed. '
pubkey = tools.privtopub(privkey)
address = tools.make_address([pubkey], 1)
if 'count' not in tx:
try:
tx['count'] = tools.count(address, {})
except:
tx['count'] = 1
# add our pubkey
if 'pubkeys' not in tx:
tx['pubkeys'] = [pubkey]
# this is IMPORTANT
# when adding new transaction which is signed by us,
# this procedure is applied. tx without signatures is signed with our privkey.
if 'signatures' not in tx:
tx['signatures'] = [tools.sign(tools.det_hash(tx), privkey)]
return blockchain.add_tx(tx)
开发者ID:coinami,项目名称:coinami-pro,代码行数:27,代码来源:api.py
示例7: get_address
def get_address(tx):
pubkey=str(raw_input('What is your address or pubkey\n>'))
if len(pubkey)>40:
out=tools.make_address([pubkey], 1)
else:
out=pubkey
return tx
开发者ID:BumblebeeBat,项目名称:FlyingFox,代码行数:7,代码来源:cli.py
示例8: sign
def sign(tx, privkey):
pubkey=tools.privtopub(privkey)
address=tools.make_address([pubkey], 1)
if 'pubkeys' not in tx:
tx['pubkeys']=[pubkey]
if 'signatures' not in tx:
tx['signatures']=[tools.sign(tools.det_hash(tx), privkey)]
return tx
开发者ID:appcoreopc,项目名称:slasher,代码行数:8,代码来源:api.py
示例9: sign
def sign(tx, privkey):
pubkey = tools.privtopub(privkey)
address = tools.make_address([pubkey], 1)
tx = add_recent_hash(tx)
if "pubkeys" not in tx:
tx["pubkeys"] = [pubkey]
if "signatures" not in tx:
tx["signatures"] = [tools.sign(tools.det_hash(tx), privkey)]
return tx
开发者ID:jtremback,项目名称:FlyingFox,代码行数:9,代码来源:api.py
示例10: easy_add_transaction
def easy_add_transaction(tx_orig, privkey, DB):
tx=copy.deepcopy(tx_orig)
pubkey=tools.privtopub(privkey)
address=tools.make_address([pubkey], 1)
try:
tx['count']=blockchain.count(address, DB)
except:
tx['count']=1
tx['signatures']=[tools.sign(tools.det_hash(tx), privkey)]
blockchain.add_tx(tx, DB)
开发者ID:AltCoinsLand,项目名称:forumcoin,代码行数:10,代码来源:gui.py
示例11: add_tx
def add_tx(tx, DB={}):
# Attempt to add a new transaction into the pool.
#print('top of add_tx')
out=['']
if type(tx) != type({'a':1}):
return False
address = tools.make_address(tx['pubkeys'], len(tx['signatures']))
def verify_count(tx, txs):
return tx['count'] != tools.count(address, DB)
def type_check(tx, txs):
if not tools.E_check(tx, 'type', [str, unicode]):
out[0]+='blockchain type'
return False
if tx['type'] == 'mint':
return False
if tx['type'] not in transactions.tx_check:
out[0]+='bad type'
return False
return True
def too_big_block(tx, txs):
return len(tools.package(txs+[tx])) > networking.MAX_MESSAGE_SIZE - 5000
def verify_tx(tx, txs, out):
if not type_check(tx, txs):
out[0]+='type error'
return False
if tx in txs:
out[0]+='no duplicates'
return False
if verify_count(tx, txs):
out[0]+='count error'
return False
if too_big_block(tx, txs):
out[0]+='too many txs'
return False
try:
if not transactions.tx_check[tx['type']](tx, txs, out, DB):
out[0]+= 'tx: ' + str(tx)
return False
except Exception as exc:
out[0]+='badly formatted tx caused error: ' +str(tx)
return False
return True
#tools.log('attempt to add tx: ' +str(tx))
T=tools.db_get('txs')
if verify_tx(tx, T, out):
T.append(tx)
tools.db_put('txs', T)
return(tx)
else:
return('failed to add tx because: '+out[0])
开发者ID:Feretrius,项目名称:augur-core,代码行数:50,代码来源:blockchain.py
示例12: add_tx
def add_tx(tx, DB={}):
# Attempt to add a new transaction into the pool.
#print('top of add_tx')
out=['']
if type(tx) != type({'a':1}):
return False
address = tools.make_address(tx['pubkeys'], len(tx['signatures']))
'''
def verify_count(tx, txs):
return tx['count'] != tools.count(address, DB)
'''
def type_check(tx, txs):
if not tools.E_check(tx, 'type', [str, unicode]):
out[0]+='blockchain type'
return False
if tx['type'] not in transactions.tx_check:
out[0]+='bad type'
return False
return True
def too_big_block(tx, txs):
return len(tools.package(txs+[tx])) > networking.MAX_MESSAGE_SIZE - 5000
def verify_tx(tx, txs, out):
#do not allow tx which fail to reference one of the 10 most recent blocks. do not allow tx which have an identical copy in the last 10 blocks.
if not type_check(tx, txs):
out[0]+='type error'
return False
if tx in txs:
out[0]+='no duplicates'
return False
#if verify_count(tx, txs):
# out[0]+='count error'
# return False
if too_big_block(tx, txs):
out[0]+='too many txs'
return False
if not transactions.tx_check[tx['type']](tx, txs, out, DB):
out[0]+= 'tx: ' + str(tx)
return False
return True
#tools.log('attempt to add tx: ' +str(tx))
T=tools.local_get('txs')
if verify_tx(tx, T, out):
T.append(tx)
tools.local_put('txs', T)
return('added tx: ' +str(tx))
else:
return('failed to add tx because: '+out[0])
开发者ID:appcoreopc,项目名称:slasher,代码行数:47,代码来源:blockchain.py
示例13: add_tx
def add_tx(tx, DB):
# Attempt to add a new transaction into the pool.
#print('top of add_tx')
out=['']
if type(tx) != type({'a':1}):
return False
address = tools.make_address(tx['pubkeys'], len(tx['signatures']))
def verify_count(tx, txs):
return tx['count'] != tools.count(address, DB)
def type_check(tx, txs):
if not tools.E_check(tx, 'type', [str, unicode]):
out[0]+='blockchain type'
return False
if tx['type'] == 'mint':
return False
if tx['type'] not in transactions.tx_check:
out[0]+='bad type'
return False
return True
def too_big_block(tx, txs):
return len(tools.package(txs+[tx])) > networking.MAX_MESSAGE_SIZE - 5000
def verify_tx(tx, txs, out):
if not type_check(tx, txs):
out[0]+='type error'
return False
if tx in txs:
out[0]+='no duplicates'
return False
if verify_count(tx, txs):
out[0]+='count error'
return False
if too_big_block(tx, txs):
out[0]+='too many txs'
return False
if not transactions.tx_check[tx['type']](tx, txs, DB):
out[0]+='update transactions.py to find out why. print statements are no good. ' +str(tx)
return False
return True
if verify_tx(tx, DB['txs'], out):
DB['txs'].append(tx)
return('added tx: ' +str(tx))
else:
return('failed to add tx because: '+out[0])
开发者ID:cartercar,项目名称:basiccoin,代码行数:43,代码来源:blockchain.py
示例14: easy_add_transaction
def easy_add_transaction(tx_orig, DB, privkey='default'):
tx = copy.deepcopy(tx_orig)
if privkey in ['default', 'Default']:
if tools.db_existence('privkey'):
privkey=tools.db_get('privkey')
else:
return('no private key is known, so the tx cannot be signed. Here is the tx: \n'+str(tools.package(tx_orig).encode('base64').replace('\n', '')))
pubkey=tools.privtopub(privkey)
address=tools.make_address([pubkey], 1)
if 'count' not in tx:
try:
tx['count'] = tools.count(address, {})
except:
tx['count'] = 1
if 'pubkeys' not in tx:
tx['pubkeys']=[pubkey]
if 'signatures' not in tx:
tx['signatures'] = [tools.sign(tools.det_hash(tx), privkey)]
return(blockchain.add_tx(tx, DB))
开发者ID:AltCoinsLand,项目名称:basiccoin,代码行数:19,代码来源:api.py
示例15: build_buy_shares
def build_buy_shares():
tx={'type':'buy_shares', 'PM_id':str(raw_input('What is the unique name for this prediction market?\n>'))}
num_states=int(raw_input('how many states does this pm have?\n>'))
tx['buy']=[]
for i in range(num_states):
tx['buy'].append(int(raw_input('how many shares do you want to buy of state '+str(i)+'? To sell states, use negative numbers.\n>')))
brainwallet=str(raw_input('What is your brainwallet\n>'))
privkey=tools.det_hash(brainwallet)
pubkey=tools.privtopub(privkey)
address=tools.make_address([pubkey], 1)
tx['pubkeys']=[pubkey]
tx['count'] = tools.count(address, {})
cost=txs_tools.cost_to_buy_shares(tx)
tx['price_limit']=int(cost*1.01)
print('now for a little proof of work. This may take several minutes. The purpose of this pow is to make it more difficult for a front runner to steal your trade.')
tx=tools.unpackage(tools.package(tx))
tx=tools.POW(tx)
tx['signatures']=[tools.sign(tools.det_hash(tx), privkey)]
print('tx for copy/pasting into pushtx: '+tools.package(tx).encode('base64'))
return tx
开发者ID:master-zhuang,项目名称:Truthcoin-POW,代码行数:20,代码来源:truth_cli.py
示例16: main
def main():
info=sys.argv
p={'command':sys.argv[1:]}
if len(p['command'])==0:
p['command'].append(' ')
c=p['command']
if c[0]=='make_PM':
tx=build_pm()
run_command({'command':['pushtx', tools.package(tx).encode('base64')]})
elif c[0]=='buy_shares':
tx=build_buy_shares()
run_command({'command':['pushtx', tools.package(tx).encode('base64')]})
elif c[0]=='start':
r=connect({'command':'blockcount'})
if is_truthcoin_off(r):
p=raw_input('what is your password?\n')
if sys.platform == 'win32':
pypath = list(os.path.split(sys.executable))
pypath[-1] = 'pythonw.exe'
os.system('start '+os.path.join(*pypath)+' threads.py '+p)
sys.exit(0)
else:
daemonize(lambda: threads.main(p))
else:
print('truthcoin is already running')
elif c[0]=='new_address':
if len(c)<2:
print('what is your brain wallet? not enough inputs.')
else:
privkey=tools.det_hash(c[1])
pubkey=tools.privtopub(privkey)
address=tools.make_address([pubkey], 1)
print('brain: ' +str(c[1]))
print('privkey: ' +str(privkey))
print('pubkey: ' +str(pubkey))
print('address: ' +str(address))
else:
run_command(p)
开发者ID:master-zhuang,项目名称:Truthcoin-POW,代码行数:38,代码来源:truth_cli.py
示例17: spend_verify
def spend_verify(tx, txs, DB):
def sigs_match(sigs, pubs, msg):
for sig in sigs:
for pub in pubs:
try:
if tools.verify(msg, sig, pub):
sigs.remove(sig)
pubs.remove(pub)
except:
pass
return len(sigs)==0
tx_copy=copy.deepcopy(tx)
tx_copy_2=copy.deepcopy(tx)
tx_copy.pop('signature')
if len(tx['id'])==0: return False
if len(tx['signature'])>len(tx['id']): return False
msg=tools.det_hash(tx_copy)
if not sigs_match(copy.deepcopy(tx['signature']), copy.deepcopy(tx['id']), msg): return False
if tx['amount']<custom.fee: return False
address=tools.make_address(tx_copy_2['id'], len(tx_copy_2['signature']))
print('tx: ' +str(tx_copy_2))
print('address: ' +str(address))
return int(blockchain.db_get(address, DB)['amount'])>=int(tx['amount'])
开发者ID:andradeandrey,项目名称:basiccoin,代码行数:23,代码来源:transactions.py
示例18: make_mint
def make_mint(pubkey, DB):
address = tools.make_address([reward_address], 1)
return {'type': 'mint',
'pubkeys': [pubkey],
'signatures': ['first_sig'],
'count': blockchain.count(address, DB)}
开发者ID:ashumeow,项目名称:basiccoin,代码行数:6,代码来源:consensus.py
注:本文中的tools.make_address函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论