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


Python CTransaction.rehash方法代码示例

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


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

示例1: mine_and_test_listunspent

# 需要导入模块: from test_framework.mininode import CTransaction [as 别名]
# 或者: from test_framework.mininode.CTransaction import rehash [as 别名]
 def mine_and_test_listunspent(self, script_list, ismine):
     utxo = find_spendable_utxo(self.nodes[0], 50)
     tx = CTransaction()
     tx.vin.append(CTxIn(COutPoint(int('0x'+utxo['txid'],0), utxo['vout'])))
     for i in script_list:
         tx.vout.append(CTxOut(10000000, i))
     tx.rehash()
     signresults = self.nodes[0].signrawtransactionwithwallet(bytes_to_hex_str(tx.serialize_without_witness()))['hex']
     txid = self.nodes[0].sendrawtransaction(signresults, True)
     self.nodes[0].generate(1)
     sync_blocks(self.nodes)
     watchcount = 0
     spendcount = 0
     for i in self.nodes[0].listunspent():
         if (i['txid'] == txid):
             watchcount += 1
             if (i['spendable'] == True):
                 spendcount += 1
     if (ismine == 2):
         assert_equal(spendcount, len(script_list))
     elif (ismine == 1):
         assert_equal(watchcount, len(script_list))
         assert_equal(spendcount, 0)
     else:
         assert_equal(watchcount, 0)
     return txid
开发者ID:994920256,项目名称:bitcoin,代码行数:28,代码来源:feature_segwit.py

示例2: mine_and_test_listunspent

# 需要导入模块: from test_framework.mininode import CTransaction [as 别名]
# 或者: from test_framework.mininode.CTransaction import rehash [as 别名]
 def mine_and_test_listunspent(self, script_list, ismine):
     utxo = find_unspent(self.nodes[0], 50)
     tx = CTransaction()
     tx.vin.append(CTxIn(COutPoint(int("0x" + utxo["txid"], 0), utxo["vout"])))
     for i in script_list:
         tx.vout.append(CTxOut(10000000, i))
     tx.rehash()
     signresults = self.nodes[0].signrawtransaction(bytes_to_hex_str(tx.serialize_without_witness()))["hex"]
     txid = self.nodes[0].sendrawtransaction(signresults, True)
     self.nodes[0].generate(1)
     sync_blocks(self.nodes)
     watchcount = 0
     spendcount = 0
     for i in self.nodes[0].listunspent():
         if i["txid"] == txid:
             watchcount += 1
             if i["spendable"] == True:
                 spendcount += 1
     if ismine == 2:
         assert_equal(spendcount, len(script_list))
     elif ismine == 1:
         assert_equal(watchcount, len(script_list))
         assert_equal(spendcount, 0)
     else:
         assert_equal(watchcount, 0)
     return txid
开发者ID:sebrandon1,项目名称:bitcoin,代码行数:28,代码来源:segwit.py

示例3: create_and_mine_tx_from_txids

# 需要导入模块: from test_framework.mininode import CTransaction [as 别名]
# 或者: from test_framework.mininode.CTransaction import rehash [as 别名]
 def create_and_mine_tx_from_txids(self, txids, success = True):
     tx = CTransaction()
     for i in txids:
         txtmp = CTransaction()
         txraw = self.nodes[0].getrawtransaction(i)
         f = BytesIO(hex_str_to_bytes(txraw))
         txtmp.deserialize(f)
         for j in range(len(txtmp.vout)):
             tx.vin.append(CTxIn(COutPoint(int('0x'+i,0), j)))
     tx.vout.append(CTxOut(0, CScript()))
     tx.rehash()
     signresults = self.nodes[0].signrawtransactionwithwallet(bytes_to_hex_str(tx.serialize_without_witness()))['hex']
     self.nodes[0].sendrawtransaction(signresults, True)
     self.nodes[0].generate(1)
     sync_blocks(self.nodes)
开发者ID:994920256,项目名称:bitcoin,代码行数:17,代码来源:feature_segwit.py

示例4: create_transaction

# 需要导入模块: from test_framework.mininode import CTransaction [as 别名]
# 或者: from test_framework.mininode.CTransaction import rehash [as 别名]
def create_transaction(node, coinbase, to_address, amount, expiry_height):
    from_txid = node.getblock(coinbase)['tx'][0]
    inputs = [{"txid": from_txid, "vout": 0}]
    outputs = {to_address: amount}
    rawtx = node.createrawtransaction(inputs, outputs)
    tx = CTransaction()

    # Set the expiry height
    f = cStringIO.StringIO(unhexlify(rawtx))
    tx.deserialize(f)
    tx.nExpiryHeight = expiry_height
    rawtx = hexlify(tx.serialize())

    signresult = node.signrawtransaction(rawtx)
    f = cStringIO.StringIO(unhexlify(signresult['hex']))
    tx.deserialize(f)
    tx.rehash()
    return tx
开发者ID:bitcartel,项目名称:zcash,代码行数:20,代码来源:tx_expiry_helper.py


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