本文整理汇总了Python中wallet.Wallet类的典型用法代码示例。如果您正苦于以下问题:Python Wallet类的具体用法?Python Wallet怎么用?Python Wallet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Wallet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: restore_multisig_wallet
def restore_multisig_wallet(self, storage, wallet_type):
# FIXME: better handling of duplicate keys
m, n = Wallet.multisig_type(wallet_type)
key_list = self.request_many(n - 1)
need_password = any(Wallet.should_encrypt(text) for text in key_list)
password = self.request_password() if need_password else None
return Wallet.from_multisig(key_list, password, storage, wallet_type)
示例2: load_wallet
def load_wallet(self, config):
path = config.get_wallet_path()
if path in self.wallets:
wallet = self.wallets[path]
else:
storage = WalletStorage(path)
wallet = Wallet(storage)
wallet.start_threads(self.network)
self.wallets[path] = wallet
return wallet
示例3: register_plugin_wallet
def register_plugin_wallet(self, name, gui_good, details):
from wallet import Wallet
def dynamic_constructor(storage):
return self.wallet_plugin_loader(name).wallet_class(storage)
if details[0] == 'hardware':
self.hw_wallets[name] = (gui_good, details)
self.print_error("registering wallet %s: %s" %(name, details))
Wallet.register_plugin_wallet(details[0], details[1],
dynamic_constructor)
示例4: load_wallet
def load_wallet(self, path, wizard=None):
if path in self.wallets:
wallet = self.wallets[path]
else:
if wizard:
wallet = wizard.open_wallet(self.network, path)
else:
storage = WalletStorage(path)
wallet = Wallet(storage)
wallet.start_threads(self.network)
if wallet:
self.wallets[path] = wallet
return wallet
示例5: verify_transaction
def verify_transaction(transaction, get_balance, check_funds=True):
"""Verify a transaction by checking whether the sender has sufficient coins.
Arguments:
:transaction: The transaction that should be verified.
"""
if check_funds:
sender_balance = get_balance(transaction.sender)
return sender_balance >= transaction.amount and Wallet.verify_transaction(transaction)
else:
return Wallet.verify_transaction(transaction)
示例6: load_wallet
def load_wallet(self, path):
if path in self.wallets:
wallet = self.wallets[path]
return wallet
storage = WalletStorage(path)
if not storage.file_exists:
return
wallet = Wallet(storage)
action = wallet.get_action()
if action:
return
wallet.start_threads(self.network)
self.wallets[path] = wallet
return wallet
示例7: load_wallet
def load_wallet(self, path):
# wizard will be launched if we return
if path in self.wallets:
wallet = self.wallets[path]
return wallet
storage = WalletStorage(path)
if not storage.file_exists:
return
if storage.requires_split() or storage.requires_upgrade() or storage.get_action():
return
wallet = Wallet(storage)
wallet.start_threads(self.network)
self.wallets[path] = wallet
return wallet
示例8: __init__
def __init__(self,):
QObject.__init__(self,)
self.thread = None
self._balance = '<b>0.00</b>000000'
self._fiatSymbol = u'€'
self._fiatRate = 0
self._fiatBalance = u'0 €'
self._wallet = Wallet()
self._wallet.onNewTransaction.connect(self.notifyNewTx)
self._walletUnlocked = False
self.settings = Settings()
self.addressesModel = AddressesModel()
self.transactionsModel = TransactionsModel()
self.timer = QTimer(self)
self.timer.setInterval(900000) # 15 min update
self.timer.timeout.connect(self.update)
self.timer.start()
if self.settings.storePassKey:
self._currentPassKey = self.settings.passKey
try:
self.unlockWallet(self._currentPassKey)
except:
self.onError.emit('Stored pass phrase is invalid')
else:
self._currentPassKey = None
self._currentAddressIndex = 0
示例9: create_or_restore
def create_or_restore(self, storage):
'''After querying the user what they wish to do, create or restore
a wallet and return it.'''
self.remove_from_recently_open(storage.path)
# Filter out any unregistered wallet kinds
registered_kinds = Wallet.categories()
kinds, descriptions = zip(*[pair for pair in WizardBase.wallet_kinds
if pair[0] in registered_kinds])
action, kind_index = self.query_create_or_restore(descriptions)
assert action in WizardBase.user_actions
kind = kinds[kind_index]
if kind == 'multisig':
wallet_type = self.query_multisig(action)
elif kind == 'hardware':
# The create/restore distinction is not obvious for hardware
# wallets; so we ask for the action again and default based
# on the prior choice :)
hw_wallet_types, choices = self.plugins.hardware_wallets(action)
msg = _('Select the type of hardware wallet: ')
action, choice = self.query_hw_wallet_choice(msg, action, choices)
wallet_type = hw_wallet_types[choice]
elif kind == 'twofactor':
wallet_type = '2fa'
else:
wallet_type = 'standard'
if action == 'create':
wallet = self.create_wallet(storage, wallet_type, kind)
else:
wallet = self.restore_wallet(storage, wallet_type, kind)
return action, wallet
示例10: add_cosigners
def add_cosigners(self, wallet):
# FIXME: better handling of duplicate keys
m, n = Wallet.multisig_type(wallet.wallet_type)
xpub1 = wallet.master_public_keys.get("x1/")
xpubs = self.request_many(n - 1, xpub1)
for i, xpub in enumerate(xpubs):
wallet.add_master_public_key("x%d/" % (i + 2), xpub)
示例11: run
def run(self, network, storage):
'''The main entry point of the wizard. Open a wallet from the given
filename. If the file doesn't exist launch the GUI-specific
install wizard proper, created by calling create_wizard().'''
need_sync = False
is_restore = False
if storage.file_exists:
wallet = Wallet(storage)
if wallet.imported_keys:
self.update_wallet_format(wallet)
else:
cr, wallet = self.create_or_restore(storage)
if not wallet:
return
need_sync = True
is_restore = (cr == 'restore')
while True:
action = wallet.get_action()
if not action:
break
need_sync = True
self.run_wallet_action(wallet, action)
# Save the wallet after each action
wallet.storage.write()
if network:
# Show network dialog if config does not exist
if self.config.get('auto_connect') is None:
self.choose_server(network)
else:
self.show_warning(_('You are offline'))
if need_sync:
self.create_addresses(wallet)
# start wallet threads
if network:
wallet.start_threads(network)
if is_restore:
self.show_restore(wallet, network)
self.finished()
return wallet
示例12: main
def main():
try:
wallet_id = sys.argv[1]
sample_wallet = None
try:
sample_wallet = Wallet(wallet_label=wallet_id,
iterate_until_send=True)
except http.WalletNotFoundError:
print "Couldn't find that wallet."
sys.exit()
for utxos in sample_wallet:
print "UTXOs: %s" % str(utxos)
print("Desired Spend (in satoshis): %d" %
sample_wallet.get_current_desired_spend())
except Exception as err:
print "Error: %s" % str(err)
print "Usage: print.py 3562f0c16b41b2f9"
示例13: load_wallet
def load_wallet(self, path, get_wizard=None):
if path in self.wallets:
wallet = self.wallets[path]
else:
storage = WalletStorage(path)
if storage.file_exists:
wallet = Wallet(storage)
action = wallet.get_action()
else:
action = 'new'
if action:
if get_wizard is None:
return None
wizard = get_wizard()
wallet = wizard.run(self.network, storage)
else:
wallet.start_threads(self.network)
if wallet:
self.wallets[path] = wallet
return wallet
示例14: open_wallet
def open_wallet(self, network, filename):
'''The main entry point of the wizard. Open a wallet from the given
filename. If the file doesn't exist launch the GUI-specific
install wizard proper.'''
storage = WalletStorage(filename)
if storage.file_exists:
wallet = Wallet(storage)
self.update_wallet_format(wallet)
task = None
else:
cr, wallet = self.create_or_restore(storage)
if not wallet:
return
task = lambda: self.show_restore(wallet, network, cr)
need_sync = False
while True:
action = wallet.get_action()
if not action:
break
need_sync = True
self.run_wallet_action(wallet, action)
# Save the wallet after each action
wallet.storage.write()
if network:
self.choose_server(network)
else:
self.show_warning(_('You are offline'))
if need_sync:
self.create_addresses(wallet)
# start wallet threads
if network:
wallet.start_threads(network)
if task:
task()
return wallet
示例15: __init__
class Cashier:
_exchanges = exchanges.actived_exchanges
def __init__(self):
self.wallet = Wallet()
self.qty_per_order = config.configuration['qty_per_order']
def post_transfers(self, buy_account, sell_account):
'''交易完成以后的比特币转账
流程:
1. 检查钱包是否有足够余额
2.1 有余额则先发送比特币给卖方
2. 买方转移比特币到钱包
'''
buy_ex = Trader._exchanges[buy_account.name]
sell_ex = Trader._exchanges[sell_account.name]
wallet_balance = self.wallet.balance()
if wallet_balance > self.qty_per_order:
self.wallet.withdraw(sell_account.stock_deposit_address, self.qty_per_order)
buy_ex.withdraw_stock(self.qty_per_order)
def make_balance(self, accounts):
wallet_balance = self.wallet.balance()
for a in accounts:
if a.stock_balance < self.qty_per_order and wallet_balance > self.qty_per_order:
_logger.info('[CASHIER]\t\t Transfering BTC from wallet to account "{0}", qty={1}'
.format(a.name, self.qty_per_order))
self.wallet.withdraw(a.stock_deposit_address, self.qty_per_order)
wallet_balance -= self.qty_per_order