• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python wallet.get_asset_definition函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: btnSellClicked

 def btnSellClicked(self):
     valid = True
     if not self.edtSellQuantity.text().toDouble()[1]:
         self.edtSellQuantity.setStyleSheet('background:#FF8080')
         valid = False
     if not self.edtSellPrice.text().toDouble()[1]:
         self.edtSellPrice.setStyleSheet('background:#FF8080')
         valid = False
     if not valid:
         return
     moniker = str(self.cbMoniker.currentText())
     asset = wallet.get_asset_definition(moniker)
     value = self.edtSellQuantity.text().toDouble()[0]
     bitcoin = wallet.get_asset_definition('bitcoin')
     price = self.edtSellPrice.text().toDouble()[0]
     delta = wallet.get_available_balance(asset) - asset.parse_value(value)
     if delta < 0:
         message = 'The transaction amount exceeds available balance by %s %s' % \
             (asset.format_value(-delta), moniker)
         QtGui.QMessageBox.critical(self, '', message, QtGui.QMessageBox.Ok)
         return
     offer = wallet.p2ptrade_make_offer(True, {
         'moniker': moniker,
         'value': value,
         'price': price,
     })
     wallet.p2p_agent.register_my_offer(offer)
     self.update_offers()
     self.edtSellQuantity.setText('')
     self.edtSellPrice.setText('')
开发者ID:CharlyRielle,项目名称:ngcccbase,代码行数:30,代码来源:tradepage.py


示例2: update_offers

    def update_offers(self):
        moniker = str(self.cbMoniker.currentText())
        if moniker == '':
            return
        bitcoin = wallet.get_asset_definition('bitcoin')
        asset = wallet.get_asset_definition(moniker)
        color_desc = asset.get_color_set().color_desc_list[0]

        wallet.p2p_agent.update()

        selected_oids = [None, None]
        viewsList = [
            [0, self.tvBuy,  self.proxyModelBuy],
            [1, self.tvSell, self.proxyModelSell],
        ]
        for i, view, proxy in viewsList:
            selected = view.selectedIndexes()
            if selected:
                index = proxy.index(selected[0].row(), 3)
                selected_oids[i] = str(proxy.data(index).toString())

        self.modelBuy.removeRows(0, self.modelBuy.rowCount())
        self.modelSell.removeRows(0, self.modelSell.rowCount())
        offers = wallet.p2p_agent.their_offers.items() + wallet.p2p_agent.my_offers.items()
        for i, item in enumerate(offers):
            oid, offer = item
            data = offer.get_data()
            if data['A'].get('color_spec') == color_desc:
                value = data['A']['value']
                total = data['B']['value']
                price = int(total*asset.unit/float(value))
                self.modelSell.addRow([
                    bitcoin.format_value(price),
                    asset.format_value(value),
                    bitcoin.format_value(total),
                    oid,
                ])
            if data['B'].get('color_spec') == color_desc:
                value = data['B']['value']
                total = data['A']['value']
                price = int(total*asset.unit/float(value))
                self.modelBuy.addRow([
                    bitcoin.format_value(price),
                    asset.format_value(value),
                    bitcoin.format_value(total),
                    oid,
                ])

        for i, view, proxy in viewsList:
            for row in xrange(proxy.rowCount()):
                oid = str(proxy.data(proxy.index(row, 3)).toString())
                if oid == selected_oids[i]:
                    view.selectRow(row)
开发者ID:kazcw,项目名称:NGCCCBase,代码行数:53,代码来源:tradepage.py


示例3: updateAvailableBalance

 def updateAvailableBalance(self):
     moniker = str(self.cbMoniker.currentText())
     if moniker:
         asset = wallet.get_asset_definition(moniker)
         balance = wallet.get_available_balance(moniker)
         self.edtAmount.setMaximum(balance)
         self.lblAvailaleBalance.setText("%s %s" % (asset.format_value(balance), moniker))
开发者ID:shadowxxx,项目名称:ngcccbase,代码行数:7,代码来源:sendcoinspage.py


示例4: update_balance

    def update_balance(self):
        moniker = str(self.cbMoniker.currentText())
        if moniker == '':
            return

        asset = wallet.get_asset_definition('bitcoin')
        value = asset.format_value(wallet.get_available_balance(asset))
        self.lblBuy.setText('<b>Buy</b> %s' % moniker)
        self.lblBuyAvail.setText('(Available: %s bitcoin)' % value)

        asset = wallet.get_asset_definition(moniker)
        value = asset.format_value(wallet.get_available_balance(asset))
        self.lblSell.setText('<b>Sell</b> %s' % moniker)
        self.lblSellAvail.setText('(Available: %s %s)' % (value, moniker))

        self.update_offers()
开发者ID:F483,项目名称:ngcccbase,代码行数:16,代码来源:tradepage.py


示例5: cbMonikerIndexChanged

    def cbMonikerIndexChanged(self):
        moniker = str(self.cbMoniker.currentText())
        if moniker == '':
            return

        asset = wallet.get_asset_definition('bitcoin')
        value = asset.format_value(wallet.get_available_balance(asset))
        text = '<b>Buy</b> {0} (Available: {1} bitcoin)'.format(moniker, value)
        self.lblBuy.setText(text)

        asset = wallet.get_asset_definition(moniker)
        value = asset.format_value(wallet.get_available_balance(asset))
        text = '<b>Sell</b> {0} (Available: {1} {0})'.format(moniker, value)
        self.lblSell.setText(text)

        self.update_offers()
开发者ID:CharlyRielle,项目名称:ngcccbase,代码行数:16,代码来源:tradepage.py


示例6: tvSellDoubleClicked

    def tvSellDoubleClicked(self):
        selected = self.tvSell.selectedIndexes()
        if not selected:
            return
        index = self.proxyModelSell.index(selected[0].row(), 3)
        oid = str(self.proxyModelSell.data(index).toString())
        if oid in wallet.p2p_agent.their_offers:
            offer = wallet.p2p_agent.their_offers[oid]
            moniker = str(self.cbMoniker.currentText())
            asset = wallet.get_asset_definition(moniker)
            if wallet.get_available_balance(asset) < offer.get_data()['A']['value']:
                QtGui.QMessageBox.warning(self, '', "Not enough money...",
                    QtGui.QMessageBox.Cancel)
                return
            message = "Buy <b>{value}</b> {moniker} for <b>{course}</b> \
bitcoin (Total: <b>{total}</b> bitcoin)".format(**{
                'value': self.proxyModelSell.data(selected[1]).toString(),
                'moniker': moniker,
                'course': self.proxyModelSell.data(selected[0]).toString(),
                'total': self.proxyModelSell.data(selected[2]).toString(),
            })
            retval = QtGui.QMessageBox.question(
                self, "Confirm buy coins", message,
                QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel,
                QtGui.QMessageBox.Cancel)
            if retval != QtGui.QMessageBox.Yes:
                return
            new_offer = wallet.p2ptrade_make_mirror_offer(offer)
            wallet.p2p_agent.register_my_offer(new_offer)
        else:
            offer = wallet.p2p_agent.my_offers[oid]
            wallet.p2p_agent.cancel_my_offer(offer)
        self.update_offers()
开发者ID:CharlyRielle,项目名称:ngcccbase,代码行数:33,代码来源:tradepage.py


示例7: contextMenuEvent

 def contextMenuEvent(self, event):
     selected = self.tableView.selectedIndexes()
     if not selected:
         return
     actions = [
         self.actionCopyMoniker,
         self.actionCopyColorSet,
         self.actionCopyUnit,
         self.actionCopyAsJSON,
         self.actionShowAddresses,
     ]
     menu = QtGui.QMenu()
     for action in actions:
         menu.addAction(action)
     result = menu.exec_(event.globalPos())
     if result is None or result not in actions:
         return
     if actions.index(result) in [0, 1, 2]:
         index = selected[actions.index(result)]
         QtGui.QApplication.clipboard().setText(
             self.proxyModel.data(index).toString())
     elif actions.index(result) == 3:
         moniker = str(self.proxyModel.data(selected[0]).toString())
         asset = wallet.get_asset_definition(moniker)
         QtGui.QApplication.clipboard().setText(
             json.dumps(asset.get_data()))
     elif actions.index(result) == 4:
         window = self.parentWidget().parentWidget().parentWidget()
         window.gotoReceivePage()
         window.receivepage.setMonikerFilter(
             self.proxyModel.data(selected[0]).toString())
开发者ID:Andymeows,项目名称:ngcccbase,代码行数:31,代码来源:assetspage.py


示例8: updateAvailableBalance

 def updateAvailableBalance(self):
     moniker = str(self.cb_monikers.currentText())
     if moniker:
         balance = wallet.get_balance(moniker)
         asset = wallet.get_asset_definition(moniker)
         self.edt_amount.setMaximum(balance)
         self.lbl_availaleBalance.setText(
             '%s %s' % (asset.format_value(balance), moniker))
开发者ID:meeh420,项目名称:ngcccbase,代码行数:8,代码来源:sendcoinspage.py


示例9: getData

 def getData(self):
     moniker = str(self.cbMoniker.currentText())
     asset = wallet.get_asset_definition(moniker)
     value = asset.parse_value(str(self.edtAmount.value()))
     return {
         'address': str(self.edtAddress.text()),
         'value':  value,
         'moniker': moniker,
     }
开发者ID:kazcw,项目名称:NGCCCBase,代码行数:9,代码来源:sendcoinspage.py


示例10: update

    def update(self):
        allowTextSelection = (
            QtCore.Qt.LinksAccessibleByMouse |
            QtCore.Qt.TextSelectableByKeyboard |
            QtCore.Qt.TextSelectableByMouse)

        self.scrollAreaContents = QtGui.QWidget()
        self.scrollArea.setWidget(self.scrollAreaContents)
        self.scrollAreaLayout = QtGui.QVBoxLayout(self.scrollAreaContents)

        hbox = QtGui.QHBoxLayout()
        hbox.addItem(QtGui.QSpacerItem(20, 0))
        hbox.setStretch(0, 1)
        updateButton = QtGui.QPushButton('Update', self.scrollAreaContents)
        updateButton.clicked.connect(self.updateButtonClicked)
        hbox.addWidget(updateButton)
        self.scrollAreaLayout.addLayout(hbox)

        for moniker in wallet.get_all_monikers():
            asset = wallet.get_asset_definition(moniker)
            address = wallet.get_some_address(asset)
            total_balance = wallet.get_total_balance(asset)
            unconfirmed_balance = wallet.get_unconfirmed_balance(asset)

            groupBox = QtGui.QGroupBox(moniker, self.scrollAreaContents)
            layout = QtGui.QFormLayout(groupBox)

            label = QtGui.QLabel(groupBox)
            label.setText('Balance:')
            layout.setWidget(0, QtGui.QFormLayout.LabelRole, label)

            balance_text = asset.format_value(total_balance)
            if not (unconfirmed_balance == 0):
                balance_text += " (%s unconfirmed, %s available)" % \
                    (asset.format_value(unconfirmed_balance),
                     asset.format_value(wallet.get_available_balance(asset)))

            label = QtGui.QLabel(groupBox)
            label.setTextInteractionFlags(allowTextSelection)
            label.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
            label.setText(balance_text)
            layout.setWidget(0, QtGui.QFormLayout.FieldRole, label)

            label = QtGui.QLabel(groupBox)
            label.setText('Address:')
            layout.setWidget(1, QtGui.QFormLayout.LabelRole, label)

            label = QtGui.QLabel(groupBox)
            label.setTextInteractionFlags(allowTextSelection)
            label.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
            label.setText(address)
            layout.setWidget(1, QtGui.QFormLayout.FieldRole, label)

            self.scrollAreaLayout.addWidget(groupBox)

        self.scrollAreaLayout.addItem(QtGui.QSpacerItem(20, 0))
        self.scrollAreaLayout.setStretch(self.scrollAreaLayout.count()-1, 1)
开发者ID:Andymeows,项目名称:ngcccbase,代码行数:57,代码来源:overviewpage.py


示例11: changeTotalBTC

 def changeTotalBTC(self):
     amount = self.edtUnits.text().toInt()
     units = self.edtAtoms.text().toInt()
     if amount[1] and units[1]:
         need = amount[0] * units[0]
         text = "%s bitcoin" % wallet.get_asset_definition("bitcoin").format_value(need)
         if need > self.availableBTC:
             text = '<font color="#FF3838">%s</font>' % text
         self.lblTotalBTC.setText(text)
开发者ID:ripplecripple,项目名称:ngcccbase,代码行数:9,代码来源:assetspage.py


示例12: lblSellTotalChange

 def lblSellTotalChange(self):
     bitcoin = wallet.get_asset_definition('bitcoin')
     quantity = self._to_decimal(self.edtSellQuantity)
     price = bitcoin.parse_value(self._to_decimal(self.edtSellPrice))
     total = quantity * price
     if total:
         self.lblSellTotal.setText('%sBTC' % bitcoin.format_value(total))
     else:
         self.lblSellTotal.setText('')
开发者ID:F483,项目名称:ngcccbase,代码行数:9,代码来源:tradepage.py


示例13: validate_sell_input

    def validate_sell_input(self, quantity, price):
        moniker = str(self.cbMoniker.currentText())
        asset = wallet.get_asset_definition(moniker)
        bitcoin = wallet.get_asset_definition('bitcoin')

        # check if quantity was given
        if quantity <= Decimal("0"): # no quantity
            self.edtSellQuantity.setStyleSheet('background:#FF8080')
            return False

        # check if price was given
        if price <= Decimal("0"): # no price
            self.edtSellPrice.setStyleSheet('background:#FF8080')
            return False

        # quantity must be multiple of atom
        if not asset.validate_value(quantity):
            atom = asset.format_value(1)
            message = "Quantity must be a multiple of %s!" % atom
            QtGui.QMessageBox.critical(self, '', message, QtGui.QMessageBox.Ok)
            self.edtSellQuantity.setStyleSheet('background:#FF8080')
            return False

        # price must be multiple of atom
        if not bitcoin.validate_value(price):
            atom = bitcoin.format_value(1)
            message = "Price must be a multiple of %s!" % atom
            QtGui.QMessageBox.critical(self, '', message, QtGui.QMessageBox.Ok)
            self.edtSellPrice.setStyleSheet('background:#FF8080')
            return False

        # check if amount exceeds available balance
        needed = asset.parse_value(quantity)
        delta = wallet.get_available_balance(asset) - needed
        if delta < 0:
            args = (asset.format_value(-delta), moniker)
            msg_str = 'The amount exceeds available balance by %s %s'
            message = msg_str % args
            QtGui.QMessageBox.critical(self, '', message, QtGui.QMessageBox.Ok)
            self.edtSellQuantity.setStyleSheet('background:#FF8080')
            self.edtSellPrice.setStyleSheet('background:#FF8080')
            return False

        return True
开发者ID:F483,项目名称:ngcccbase,代码行数:44,代码来源:tradepage.py


示例14: validate_buy_input

    def validate_buy_input(self, quantity, price):
        moniker = str(self.cbMoniker.currentText())
        asset = wallet.get_asset_definition(moniker)
        bitcoin = wallet.get_asset_definition('bitcoin')

        # check if quantity was given
        if quantity <= Decimal("0"): # no quantity
            self.edtBuyQuantity.setStyleSheet('background:#FF8080')
            return False

        # check if price was given
        if price <= Decimal("0"): # no price
            self.edtBuyPrice.setStyleSheet('background:#FF8080')
            return False

        # quantity must be multiple of atom
        if not asset.validate_value(quantity):
            message = "Quantity must be a multiple of %s!" % asset.get_atom()
            QtGui.QMessageBox.critical(self, '', message, QtGui.QMessageBox.Ok)
            self.edtBuyQuantity.setStyleSheet('background:#FF8080')
            return False

        # price must be multiple of atom
        if not bitcoin.validate_value(price):
            message = "Price must be a multiple of %s!" % asset.get_atom()
            QtGui.QMessageBox.critical(self, '', message, QtGui.QMessageBox.Ok)
            self.edtBuyPrice.setStyleSheet('background:#FF8080')
            return False

        # check if amount exceeds available balance
        needed = quantity * bitcoin.parse_value(price)
        available = wallet.get_available_balance(bitcoin)
        delta = available - needed
        if delta < 0:
            neg_delta = bitcoin.format_value(-delta)
            msg_str = 'The amount exceeds available balance by %s bitcoin!'
            message = msg_str % neg_delta
            QtGui.QMessageBox.critical(self, '', message, QtGui.QMessageBox.Ok)
            self.edtBuyQuantity.setStyleSheet('background:#FF8080')
            self.edtBuyPrice.setStyleSheet('background:#FF8080')
            return False

        return True
开发者ID:F483,项目名称:ngcccbase,代码行数:43,代码来源:tradepage.py


示例15: lblSellTotalChange

 def lblSellTotalChange(self):
     self.lblSellTotal.setText('')
     if self.edtSellQuantity.text().toDouble()[1] \
             and self.edtSellPrice.text().toDouble()[1]:
         value = self.edtSellQuantity.text().toDouble()[0]
         bitcoin = wallet.get_asset_definition('bitcoin')
         price = bitcoin.parse_value(
             self.edtSellPrice.text().toDouble()[0])
         total = value*price
         self.lblSellTotal.setText('%s bitcoin' % bitcoin.format_value(total))
开发者ID:CharlyRielle,项目名称:ngcccbase,代码行数:10,代码来源:tradepage.py


示例16: updateWallet

 def updateWallet(self):
     moniker = str(self.cb_monikers.currentText())
     if moniker == '':
         return
     asset = wallet.get_asset_definition(moniker)
     balance = wallet.get_balance(asset)
     self.lbl_balance.setText(
         '%s %s' % (asset.format_value(balance), moniker))
     wam = wallet.model.get_address_manager()
     addr = wam.get_some_address(asset.get_color_set()).get_address()
     self.lbl_address.setText(addr)
开发者ID:meeh420,项目名称:ngcccbase,代码行数:11,代码来源:overviewpage.py


示例17: update

    def update(self):
        self.model.removeRows(0, self.model.rowCount())
        for moniker in wallet.get_all_monikers():
            asset = wallet.get_asset_definition(moniker)
            for row in wallet.get_address_balance(asset):
                self.model.addRow([moniker, row['color_address'], asset.format_value(row['value'])])

        moniker = self.cbMoniker.currentText()
        monikers = [''] + wallet.get_all_monikers()
        self.cbMoniker.clear()
        self.cbMoniker.addItems(monikers)
        if moniker in monikers:
            self.cbMoniker.setCurrentIndex(monikers.index(moniker))
        self.setMonikerFilter(self.cbMoniker.currentText())
开发者ID:MattFaus,项目名称:ngcccbase,代码行数:14,代码来源:receivepage.py


示例18: __init__

    def __init__(self, parent):
        QtGui.QDialog.__init__(self, parent)
        uic.loadUi(uic.getUiPath('issuedialog.ui'), self)

        self.cbScheme.addItem('obc')

        for wname in ['edtMoniker', 'edtUnits', 'edtAtoms']:
            getattr(self, wname).focusInEvent = \
                lambda e, name=wname: getattr(self, name).setStyleSheet('')

        self.edtUnits.textChanged.connect(self.changeTotalBTC)
        self.edtAtoms.textChanged.connect(self.changeTotalBTC)

        self.availableBTC = wallet.get_balance('bitcoin')
        self.lblTotalBTC.setToolTip('Available: %s bitcoin' % \
            wallet.get_asset_definition('bitcoin').format_value(self.availableBTC))
开发者ID:kazcw,项目名称:NGCCCBase,代码行数:16,代码来源:assetpage.py


示例19: information_about_offer

 def information_about_offer(offer, action, buysell_text):
     A, B = offer.get_data()['A'], offer.get_data()['B']
     bitcoin = wallet.get_asset_definition('bitcoin')
     sell_offer = B['color_spec'] == ''
     asset = wallet.get_asset_definition_by_color_set(
         (A if sell_offer else B)['color_spec'])
     value = (A if sell_offer else B)['value']
     total = (B if sell_offer else A)['value']
     text = '{action} {type} {value} {moniker} @{price} btc ea. (Total: {total} btc)'.format(**{
         'action': action,
         'type': buysell_text[sell_offer],
         'value': asset.format_value(value),
         'moniker': asset.get_monikers()[0],
         'price': bitcoin.format_value(total*asset.unit/value),
         'total': bitcoin.format_value(total),
     })
     self.add_log_entry(text)
开发者ID:Andymeows,项目名称:ngcccbase,代码行数:17,代码来源:tradepage.py


示例20: information_about_offer

 def information_about_offer(offer, action='Create'):
     A, B = offer.get_data()['A'], offer.get_data()['B']
     bitcoin = wallet.get_asset_definition('bitcoin')
     sell_offer = B['color_spec'] == ''
     asset = wallet.get_asset_definition_by_color_set(
         (A if sell_offer else B)['color_spec'])
     value = (A if sell_offer else B)['value']
     total = (B if sell_offer else A)['value']
     text = '{action} {type} offer {value} {moniker} for {price} btc. (Total: {total} btc)'.format(**{
         'action': action,
         'type': 'sell' if sell_offer else 'buy',
         'value': asset.format_value(value),
         'moniker': asset.get_monikers()[0],
         'price': bitcoin.format_value(total*asset.unit/value),
         'total': bitcoin.format_value(total),
     })
     QtGui.QMessageBox.information(self,
         '{action} offer'.format(action=action), text, QtGui.QMessageBox.Yes)
开发者ID:CharlyRielle,项目名称:ngcccbase,代码行数:18,代码来源:tradepage.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python compat.nested函数代码示例发布时间:2022-05-26
下一篇:
Python wallet.Wallet类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap