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


Python BtcTxStore.storenulldata方法代码示例

本文整理汇总了Python中btctxstore.BtcTxStore.storenulldata方法的典型用法代码示例。如果您正苦于以下问题:Python BtcTxStore.storenulldata方法的具体用法?Python BtcTxStore.storenulldata怎么用?Python BtcTxStore.storenulldata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在btctxstore.BtcTxStore的用法示例。


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

示例1: generate_block

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import storenulldata [as 别名]
    def generate_block(self):
        """Close the current block, and generate a new one."""

        try:
            last_block = latest_block(self.conn)
            last_hash = latest_hash(self.conn)

            # Get Merkle Root
            self.find_leaves()
            self.close()
            merkle_root = self.merkle_root()

            # Get TXID
            hexdata = merkle_root
            privatekeys = app.config["PRIVATE_KEYS"]
            changeaddress = app.config["CHANGE_ADDRESS"]
            fee = app.config["FEE"]
            testnet = app.config["TESTNET"]
            blockchain = BtcTxStore(testnet=testnet)
            tx_id = blockchain.storenulldata(hexdata, privatekeys, 
                                             changeaddress=changeaddress,
                                             fee=fee)

            # Close current block
            c = self.conn.cursor()
            query1 = "UPDATE block_table SET end_hash=?, closed=?, merkle_root=?, tx_id=? WHERE id=?"
            c.execute(query1, (last_hash, True, merkle_root, tx_id, last_block))

            # Start new block
            query2 = "INSERT INTO block_table (start_hash) VALUES (?)"
            c.execute(query2, (last_hash,))

            self.conn.commit()
            self.conn.close()
            return 'Block {0} Built.'.format(last_block)
        except LookupError:
            return 'Block Empty.'
开发者ID:F483,项目名称:hashserv,代码行数:39,代码来源:DataBlock.py

示例2: TestStoreNulldata

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import storenulldata [as 别名]
class TestStoreNulldata(unittest.TestCase):

    def setUp(self):
        self.api = BtcTxStore(dryrun=True, testnet=True)

    def test_storenulldata_alpha(self):
        wifs = fixtures["storenulldata"]["alpha"]["wifs"]
        result = self.api.storenulldata("f483", wifs)
        expected = fixtures["storenulldata"]["alpha"]["expected"]
        self.assertEqual(result, expected)

    def test_storenulldata_beta(self):
        wifs = fixtures["storenulldata"]["beta"]["wifs"]
        expected = fixtures["storenulldata"]["beta"]["expected"]
        data = binascii.hexlify(b"github.com/F483/btctxstore")
        result = self.api.storenulldata(data, wifs)
        self.assertEqual(result, expected)

    def test_storenulldata_insufficient_funds(self):
        wifs = fixtures["storenulldata"]["insufficient_funds"]["wifs"]
        data = binascii.hexlify(b"f483")

        def callback():
            self.api.storenulldata(data, wifs)
        self.assertRaises(exceptions.InsufficientFunds, callback)

    def test_storenulldata_txouts(self):
        wifs = fixtures["storenulldata"]["txouts"]["wifs"]
        txouts = fixtures["storenulldata"]["txouts"]["txouts"]
        expected = fixtures["storenulldata"]["txouts"]["expected"]
        result = self.api.storenulldata("f483", wifs, txouts=txouts)
        self.assertEqual(result, expected)

    def test_storenulldata_changeaddress(self):
        _fixtures = fixtures["storenulldata"]["changeaddress"]
        wifs = _fixtures["wifs"]
        changeaddress = _fixtures["changeaddress"]
        expected = _fixtures["expected"]
        result = self.api.storenulldata("f483", wifs, changeaddress)
        self.assertEqual(result, expected)
开发者ID:NinjaDevelper,项目名称:btctxstore,代码行数:42,代码来源:api.py

示例3: Copyright

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import storenulldata [as 别名]
#!/usr/bin/env python
# coding: utf-8
# Copyright (c) 2015 Fabian Barkhau <[email protected]>
# License: MIT (see LICENSE file)

from __future__ import print_function
from __future__ import unicode_literals
import binascii
from btctxstore import BtcTxStore

# Wallet used to pay for fee. Please do not spend the testnet coins is
# this wallet or the example will fail due to lack of funds.
wifs = ["cUZfG8KJ3BrXneg2LjUX4VoMg76Fcgx6QDiAZj2oGbuw6da8Lzv1"]

# use testnet and dont post tx to blockchain for example
api = BtcTxStore(testnet=True, dryrun=True)

# store data in blockchain as nulldata output (max 40bytes)
data = binascii.hexlify(b"github.com/F483/btctxstore")
txid = api.storenulldata(data, wifs)
print(txid)
开发者ID:NinjaDevelper,项目名称:btctxstore,代码行数:23,代码来源:storenulldata.py


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