Python bitcoin.core.COutPoint() Examples
The following are 13
code examples of bitcoin.core.COutPoint().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bitcoin.core
, or try the search function
.
Example #1
Source File: test_connectors.py From cert-issuer with MIT License | 7 votes |
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
Example #2
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 6 votes |
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
Example #3
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 6 votes |
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
Example #4
Source File: tx_utils.py From cert-issuer with MIT License | 6 votes |
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
Example #5
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 6 votes |
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
Example #6
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 6 votes |
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
Example #7
Source File: utxo.py From clove with GNU General Public License v3.0 | 5 votes |
def outpoint(self): return COutPoint(lx(self.tx_id), self.vout)
Example #8
Source File: transactions.py From OpenBazaar-Server with MIT License | 5 votes |
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)
Example #9
Source File: channel.py From Lightning with MIT License | 5 votes |
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)
Example #10
Source File: channel.py From Lightning with MIT License | 5 votes |
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())
Example #11
Source File: test_jsonrpcproxy.py From Lightning with MIT License | 5 votes |
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)
Example #12
Source File: test_chainparams.py From hashmal with GNU General Public License v3.0 | 5 votes |
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)
Example #13
Source File: channel.py From Lightning with MIT License | 4 votes |
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)