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


Python core.COutPoint方法代码示例

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


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

示例1: listunspent

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import COutPoint [as 别名]
def listunspent(self, minconf=0, maxconf=9999999, addrs=None):
        """Return unspent transaction outputs in wallet

        Outputs will have between minconf and maxconf (inclusive)
        confirmations, optionally filtered to only include txouts paid to
        addresses in addrs.
        """
        r = None
        if addrs is None:
            r = self._call('listunspent', minconf, maxconf)
        else:
            addrs = [str(addr) for addr in addrs]
            r = self._call('listunspent', minconf, maxconf, addrs)

        r2 = []
        for unspent in r:
            unspent['outpoint'] = COutPoint(lx(unspent['txid']), unspent['vout'])
            del unspent['txid']
            del unspent['vout']

            unspent['address'] = CBitcoinAddress(unspent['address'])
            unspent['scriptPubKey'] = CScript(unhexlify(unspent['scriptPubKey']))
            unspent['amount'] = int(unspent['amount'] * COIN)
            r2.append(unspent)
        return r2 
开发者ID:petertodd,项目名称:checklocktimeverify-demos,代码行数:27,代码来源:rpc.py

示例2: mock_listunspent

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import COutPoint [as 别名]
def mock_listunspent(self, addrs):
    output1 = {'outpoint': COutPoint(lx('34eb81bc0d1a822369f75174fd4916b1ec490d8fbcba33168e820cc78a52f608'), 0),
               'confirmations': 62952, 'address': P2PKHBitcoinAddress('mz7poFND7hVGRtPWjiZizcCnjf6wEDWjjT'),
               'spendable': False, 'amount': 49000000, 'solvable': False, 'scriptPubKey': CScript(
            [OP_DUP, OP_HASH160, x('cc0a909c4c83068be8b45d69b60a6f09c2be0fda'), OP_EQUALVERIFY, OP_CHECKSIG]),
               'account': ''}
    output2 = {'address': P2PKHBitcoinAddress('mz7poFND7hVGRtPWjiZizcCnjf6wEDWjjT'), 'amount': 2750, 'account': '',
               'spendable': False, 'solvable': False, 'confirmations': 62932,
               'outpoint': COutPoint(lx('6773785b4dc5d2cced67d26fc0820329307a8e10dfaef50d506924984387bf0b'), 1),
               'scriptPubKey': CScript(
                   [OP_DUP, OP_HASH160, x('cc0a909c4c83068be8b45d69b60a6f09c2be0fda'), OP_EQUALVERIFY,
                    OP_CHECKSIG])}
    output3 = {'address': P2PKHBitcoinAddress('mz7poFND7hVGRtPWjiZizcCnjf6wEDWjjT'), 'amount': 2750, 'account': '',
               'spendable': False, 'solvable': False, 'confirmations': 62932,
               'outpoint': COutPoint(lx('6773785b4dc5d2cced67d26fc0820329307a8e10dfaef50d506924984387bf0b'), 5),
               'scriptPubKey': CScript(
                   [OP_DUP, OP_HASH160, x('cc0a909c4c83068be8b45d69b60a6f09c2be0fda'), OP_EQUALVERIFY,
                    OP_CHECKSIG])}
    unspent_outputs = [output1, output2, output3]
    return unspent_outputs 
开发者ID:blockchain-certificates,项目名称:cert-issuer,代码行数:22,代码来源:test_connectors.py

示例3: create_trx

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import COutPoint [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

示例4: outpoint

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import COutPoint [as 别名]
def outpoint(self):
        return COutPoint(lx(self.tx_id), self.vout) 
开发者ID:Lamden,项目名称:clove,代码行数:4,代码来源:utxo.py

示例5: make_unsigned

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import COutPoint [as 别名]
def make_unsigned(cls, outpoints, outputs, tx_fee=TRANSACTION_FEE, testnet=False, out_value=None):
        """
        Build an unsigned transaction.

        Args:
            outpoints: A `list` of `dict` objects which contain a txid, vout, value, and scriptPubkey.
            outputs: If a single address the full value of the inputs (minus the tx fee) will be sent there.
                Otherwise it should be a `list` of `dict` objects containing address and value.
            tx_fee: The Bitcoin network fee to be paid on this transaction.
            testnet: Should this transaction be built for testnet?
            out_value: used if you want to specify a specific output value otherwise the full value
                of the inputs (minus the tx fee) will be used.
        """
        # build the inputs from the outpoints object
        SelectParams("testnet" if testnet else "mainnet")
        txins = []
        in_value = 0
        for outpoint in outpoints:
            in_value += outpoint["value"]
            txin = CMutableTxIn(COutPoint(lx(outpoint["txid"]), outpoint["vout"]))
            txin.scriptSig = CScript(x(outpoint["scriptPubKey"]))
            txins.append(txin)

        # build the outputs
        txouts = []
        if isinstance(outputs, list):
            for output in outputs:
                value = output["value"]
                address = output["address"]
                txouts.append(CMutableTxOut(value, CBitcoinAddress(address).to_scriptPubKey()))
        else:
            value = out_value if out_value is not None else (in_value - tx_fee)
            txouts.append(CMutableTxOut(value, CBitcoinAddress(outputs).to_scriptPubKey()))

        # make the transaction
        tx = CMutableTransaction(txins, txouts)

        return BitcoinTransaction(tx) 
开发者ID:OpenBazaar,项目名称:OpenBazaar-Server,代码行数:40,代码来源:transactions.py

示例6: open_channel

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import COutPoint [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

示例7: update_anchor

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import COutPoint [as 别名]
def update_anchor(address, new_anchor, their_sig):
    """Update the anchor txid after both have signed."""
    channel = Channel.query.get(address)
    channel.anchor_point = COutPoint(new_anchor, channel.anchor_point.n)
    channel.their_sig = their_sig
    database.session.commit()
    return channel.signature(channel.commitment()) 
开发者ID:hashplex,项目名称:Lightning,代码行数:9,代码来源:channel.py

示例8: test_json_roundtrip

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import COutPoint [as 别名]
def test_json_roundtrip(self):
        VALUES = [
            42, 0, -42, 2100000000000000, -2100000000000000,
            "basic string", "\u1111Unicode", "\U00010000Wide Unicode",
            "\x00\n\t\r\nEscape codes", "\"'\"Quotes", "",
            None,
            b"\x00\x01\xFFBinary data", b"",
            CBase58Data.from_bytes(b'\x00\x01\xFF', 42),
            P2SHBitcoinAddress.from_bytes(b'\x00\x01\xFF'),
            P2PKHBitcoinAddress.from_bytes(b'\x00\x01\xFF'),
            CMutableTxIn(COutPoint(b'\x00'*16+b'\xFF'*16, 42),
                         CScript(b'\x00\x01\xFF'),
                         42),
            CMutableTxOut(42, CScript(b'\x00\x01\xFF')),
            CMutableTransaction([CMutableTxIn(COutPoint(b'\x00'*32, 42),
                                              CScript(b'\x00\x01\xFF'),
                                              42),
                                 CMutableTxIn(COutPoint(b'\xFF'*32, 42),
                                              CScript(b'\xFF\x01\x00'),
                                              43)],
                                [CMutableTxOut(42, CScript(b'\x00\x01\xFF')),
                                 CMutableTxOut(43, CScript(b'\xFF\x01\x00'))],
                                42, 3),
            [1, b'\x00\x01\xFF', "List Test",],
            {'a':1, 'key':b'\xFF\x01\x00', 1:'Dictionary Test'},
            [{3: [0, 1, 2,],}, [[b'\xFFRecursion Test',],],],
        ]
        for value in VALUES:
            self.assertEqual(from_json(to_json(value)), value) 
开发者ID:hashplex,项目名称:Lightning,代码行数:31,代码来源:test_jsonrpcproxy.py

示例9: test_init_with_field_keyword_args

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import COutPoint [as 别名]
def test_init_with_field_keyword_args(self):
        ins = (
            CTxIn(COutPoint(lx('537ecb89e5ed7e872f988447432e6791c0a58b069c4ec8647e1683a383e867a3'), 0),
                  x('473044022043b9aee9187effd7e6c7bc444b09162570f17e36b4a9c02cf722126cc0efa3d502200b3ba14c809fa9a6f7f835cbdbbb70f2f43f6b30beaf91eec6b8b5981c80cea50121025edf500f18f9f2b3f175f823fa996fbb2ec52982a9aeb1dc2e388a651054fb0f'))
        )
        outs = (
            CTxOut(114263, x('76a91495efca2c6a6f0e0f0ce9530219b48607a962e77788ac')),
            CTxOut(2125893, x('76a914f28abfb465126d6772dcb4403b9e1ad2ea28a03488ac'))
        )
        fields_data = {'Timestamp': 1432478808}
        tx = Transaction(ins, outs, 0, 2, peercoin_fields, fields_data)
        self.assertEqual(tx.fields, peercoin_fields)
        self.assertEqual(tx.Timestamp, 1432478808) 
开发者ID:mazaclub,项目名称:hashmal,代码行数:15,代码来源:test_chainparams.py

示例10: create

# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import COutPoint [as 别名]
def create(url, mymoney, theirmoney, fees=10000):
    """Open a payment channel.

    After this method returns, a payment channel will have been established
    with the node identified by url, in which you can send mymoney satoshis
    and recieve theirmoney satoshis. Any blockchain fees involved in the
    setup and teardown of the channel should be collected at this time.
    """
    bob = jsonrpcproxy.Proxy(url+'channel/')
    # Choose inputs and change output
    coins, change = select_coins(mymoney + 2 * fees)
    pubkey = get_pubkey()
    my_out_addr = g.bit.getnewaddress()
    # Tell Bob we want to open a channel
    transaction, redeem, their_out_addr = bob.open_channel(
        g.addr, theirmoney, mymoney, fees,
        coins, change,
        pubkey, my_out_addr)
    # Sign and send the anchor
    transaction = g.bit.signrawtransaction(transaction)
    assert transaction['complete']
    transaction = transaction['tx']
    g.bit.sendrawtransaction(transaction)
    # Set up the channel in the DB
    channel = Channel(address=url,
                      anchor_point=COutPoint(transaction.GetHash(), 0),
                      anchor_index=1,
                      their_sig=b'',
                      anchor_redeem=redeem,
                      our_balance=mymoney,
                      our_addr=my_out_addr,
                      their_balance=theirmoney,
                      their_addr=their_out_addr,
                     )
    # Exchange signatures for the inital commitment transaction
    channel.their_sig = \
        bob.update_anchor(g.addr, transaction.GetHash(),
                          channel.signature(channel.commitment()))
    database.session.add(channel)
    database.session.commit()
    # Event: channel opened
    CHANNEL_OPENED.send('channel', address=url) 
开发者ID:hashplex,项目名称:Lightning,代码行数:44,代码来源:channel.py


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