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


Python core.CMutableTransaction方法代码示例

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


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

示例1: create_trx

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import CMutableTransaction [as 别名]
def create_trx(op_return_val, issuing_transaction_fee, issuing_address, tx_outs, tx_inputs):
    """

    :param op_return_val:
    :param issuing_transaction_fee:
    :param issuing_address:
    :param tx_outs:
    :param tx_input:
    :return:
    """
    cert_out = CMutableTxOut(0, CScript([OP_RETURN, op_return_val]))
    tx_ins = []
    value_in = 0
    for tx_input in tx_inputs:
        tx_ins.append(CTxIn(COutPoint(tx_input.tx_hash, tx_input.tx_out_index)))
        value_in += tx_input.coin_value

    # send change back to our address
    amount = value_in - issuing_transaction_fee
    if amount > 0:
        change_out = create_transaction_output(issuing_address, amount)
        tx_outs = tx_outs + [change_out]
    tx_outs = tx_outs + [cert_out]
    transaction = CMutableTransaction(tx_ins, tx_outs)
    return transaction 
开发者ID:blockchain-certificates,项目名称:cert-issuer,代码行数:27,代码来源:tx_utils.py

示例2: create_unsigned_transaction

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import CMutableTransaction [as 别名]
def create_unsigned_transaction(self):
        assert self.utxo_value >= self.value, 'You want to spend more than you\'ve got. Add more UTXO\'s.'
        self.build_outputs()
        self.tx = CMutableTransaction(self.tx_in_list, self.tx_out_list, nLockTime=self.tx_locktime) 
开发者ID:Lamden,项目名称:clove,代码行数:6,代码来源:transaction.py

示例3: commitment

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import CMutableTransaction [as 别名]
def commitment(self, ours=False):
        """Return an unsigned commitment transaction."""
        first = CMutableTxOut(self.our_balance, self.our_addr.to_scriptPubKey())
        second = CMutableTxOut(self.their_balance, self.their_addr.to_scriptPubKey())
        if not ours:
            first, second = second, first
        return CMutableTransaction([CMutableTxIn(self.anchor_point)],
                                   [first, second]) 
开发者ID:hashplex,项目名称:Lightning,代码行数:10,代码来源:channel.py

示例4: settlement

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import CMutableTransaction [as 别名]
def settlement(self):
        """Generate the settlement transaction."""
        # Put outputs in the order of the inputs, so that both versions are the same
        first = CMutableTxOut(self.our_balance,
                              self.our_addr.to_scriptPubKey())
        second = CMutableTxOut(self.their_balance,
                               self.their_addr.to_scriptPubKey())
        if self.anchor_index == 0:
            pass
        elif self.anchor_index == 1:
            first, second = second, first
        else:
            raise Exception("Unknown index", self.anchor_index)
        return CMutableTransaction([CMutableTxIn(self.anchor_point)],
                                   [first, second]) 
开发者ID:hashplex,项目名称:Lightning,代码行数:17,代码来源:channel.py

示例5: open_channel

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import CMutableTransaction [as 别名]
def open_channel(address, mymoney, theirmoney, fees, their_coins, their_change, their_pubkey, their_out_addr): # pylint: disable=too-many-arguments, line-too-long
    """Open a payment channel."""
    # Get inputs and change output
    coins, change = select_coins(mymoney + 2 * fees)
    # Make the anchor script
    anchor_output_script = anchor_script(get_pubkey(), their_pubkey)
    # Construct the anchor utxo
    payment = CMutableTxOut(mymoney + theirmoney + 2 * fees,
                            anchor_output_script.to_p2sh_scriptPubKey())
    # Anchor tx
    transaction = CMutableTransaction(
        their_coins + coins,
        [payment, change, their_change])
    # Half-sign
    transaction = g.bit.signrawtransaction(transaction)['tx']
    # Create channel in DB
    our_addr = g.bit.getnewaddress()
    channel = Channel(address=address,
                      anchor_point=COutPoint(transaction.GetHash(), 0),
                      anchor_index=0,
                      their_sig=b'',
                      anchor_redeem=anchor_output_script,
                      our_balance=mymoney,
                      our_addr=our_addr,
                      their_balance=theirmoney,
                      their_addr=their_out_addr,
                     )
    database.session.add(channel)
    database.session.commit()
    # Event: channel opened
    CHANNEL_OPENED.send('channel', address=address)
    return (transaction, anchor_output_script, our_addr) 
开发者ID:hashplex,项目名称:Lightning,代码行数:34,代码来源:channel.py


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