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


Python CTransaction.vout方法代码示例

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


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

示例1: SignatureHash

# 需要导入模块: from bitcoin.core import CTransaction [as 别名]
# 或者: from bitcoin.core.CTransaction import vout [as 别名]
def SignatureHash(script, txTo, inIdx, hashtype):
    if inIdx >= len(txTo.vin):
        return (0, "inIdx %d out of range (%d)" % (inIdx, len(txTo.vin)))
    txtmp = CTransaction()
    txtmp.copy(txTo)

    for txin in txtmp.vin:
        txin.scriptSig = b''
    txtmp.vin[inIdx].scriptSig = script.vch

    if (hashtype & 0x1f) == SIGHASH_NONE:
        txtmp.vout = []

        for i in range(len(txtmp.vin)):
            if i != inIdx:
                txtmp.vin[i].nSequence = 0

    elif (hashtype & 0x1f) == SIGHASH_SINGLE:
        outIdx = inIdx
        if outIdx >= len(txtmp.vout):
            return (0, "outIdx %d out of range (%d)" % (outIdx, len(txtmp.vout)))

        tmp = txtmp.vout[outIdx]
        txtmp.vout = []
        for i in range(outIdx):
            txtmp.vout.append(CTxOut())
        txtmp.vout.append(tmp)

        for i in range(len(txtmp.vin)):
            if i != inIdx:
                txtmp.vin[i].nSequence = 0

    if hashtype & SIGHASH_ANYONECANPAY:
        tmp = txtmp.vin[inIdx]
        txtmp.vin = []
        txtmp.vin.append(tmp)

    s = txtmp.serialize()
    s += struct.pack(b"<I", hashtype)

    hash = Hash(s)

    return (hash,)
开发者ID:XertroV,项目名称:python-bitcoinlib,代码行数:45,代码来源:scripteval.py

示例2: str_money_value

# 需要导入模块: from bitcoin.core import CTransaction [as 别名]
# 或者: from bitcoin.core.CTransaction import vout [as 别名]
        (len(tx.serialize()) / 1000,
         str_money_value(value_in-value_out),
         str_money_value((value_in-value_out) / len(tx.serialize()) * 1000)))


if not args.dryrun:
    txid = rpc.sendrawtransaction(tx)
    logging.info('Sent payment tx: %s' % b2lx(txid))

if not args.dryrun:
    logging.info('Sleeping for %d seconds' % args.delay)
    time.sleep(args.delay)


# Double-spend! Remove all but the change output
tx.vout = tx.vout[0:1]
change_txout = tx.vout[0]
value_out = value_in
change_txout.nValue = value_out

# FIXME: need to modularize this code
while (value_in - value_out) / len(tx.serialize()) < feeperbyte2:
    # What's the delta fee that we need to get to our desired fees per byte at
    # the current tx size?
    delta_fee = math.ceil((feeperbyte2 * len(tx.serialize())) - (value_in - value_out))

    logging.debug('Delta fee: %s' % str_money_value(delta_fee))

    # If we simply subtract that from the change outpoint are we still above
    # the dust threshold?
    if change_txout.nValue - delta_fee > args.dust:
开发者ID:peschir,项目名称:replace-by-fee-tools,代码行数:33,代码来源:doublespend.py

示例3: CTxIn

# 需要导入模块: from bitcoin.core import CTransaction [as 别名]
# 或者: from bitcoin.core.CTransaction import vout [as 别名]
from bitcoin.core import CBlock
from bitcoin.core import CTxIn, CTxOut, CTransaction

txin = CTxIn()
txout = CTxOut()

txin.scriptSig = 0x04FFFF001D0104455468652054696D65732030332F4A616E2F32303039204368616E63656C6C6F72206F6E206272696E6B206F66207365636F6E64206261696C6F757420666F722062616E6B73
txin.prevout = 0x0000000000000000000000000000000000000000000000000000000000000000FFFFFFFF
print txin, txin.is_valid()
tx.vout.nValue = 5000000000
tx.vout.scriptPubKey = 0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704

tx = CTransaction()
tx.vin = [txin]
tx.vout = [txout]
"""
tx.vout.scriptPubKey = 0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704 OP_CHECKSIG
"""

block = CBlock()
block.nVersion = 1
block.hashPrevBlock = 0
block.hashMerkleRoot = 0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
block.nTime    = 1231006505
block.nBits    = 0x1d00ffff
block.nNonce   = 2083236893
block.vtx = [tx]
block.sha256 = 0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
print block.is_valid()
开发者ID:obulpathi,项目名称:bitcointools,代码行数:31,代码来源:genesis.py


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