def p2porders(self, moniker="", sellonly=False, buyonly=False): """Show peer to peer trade orders""" # sanitize inputs sellonly = sanitize.flag(sellonly) buyonly = sanitize.flag(buyonly) asset = None if moniker and moniker != 'bitcoin': asset = sanitize.asset(self.model, moniker) # get offers agent = self._init_p2ptrade() agent.update() offers = agent.their_offers.values() offers = map(lambda offer: offer.get_data(), offers) # filter asset if given if asset: descs = asset.get_color_set().color_desc_list def func(offer): return (offer["A"]["color_spec"] in descs or offer["B"]["color_spec"] in descs) offers = filter(func, offers) # filter sellonly if given if sellonly: offers = filter(lambda o: o["A"]["color_spec"] != "", offers) # filter buyonly if given if buyonly: offers = filter(lambda o: o["A"]["color_spec"] == "", offers) return _print(offers)
def getbalance(self, moniker, unconfirmed=False, available=False): """Returns the balance for a particular asset.""" # sanitize inputs asset = sanitize.asset(self.model, moniker) unconfirmed = sanitize.flag(unconfirmed) available = sanitize.flag(available) balance = dict([self._getbalance(asset, unconfirmed, available)]) return _print(balance)
def getbalances(self, unconfirmed=False, available=False): """Returns the balances for all assets/colors.""" # sanitize inputs unconfirmed = sanitize.flag(unconfirmed) available = sanitize.flag(available) assets = self.controller.get_all_assets() func = lambda asset: self._getbalance(asset, unconfirmed, available) balances = dict(map(func, assets)) return _print(balances)
def __init__(self, wallet=None, testnet=False): # sanitize inputs testnet = sanitize.flag(testnet) if not wallet: wallet = "%s.wallet" % ("testnet" if testnet else "mainnet") self.wallet = PersistentWallet(wallet, testnet) self.model_is_initialized = False
def __init__(self, wallet=None, testnet=False): # sanitize inputs testnet = sanitize.flag(testnet) if not wallet: wallet = "%s.wallet" % ("testnet" if testnet else "mainnet") self.wallet = PersistentWallet(wallet, testnet) self.wallet.init_model() self.model = self.wallet.get_model() self.controller = WalletController(self.model)