def test_cold_storage(self): if TRAVIS and sys.version_info[:2] != (3, 6): return private_key = PrivateKeyTestnet(WALLET_FORMAT_TEST) address = private_key.address prepared = PrivateKeyTestnet.prepare_transaction( address, [('n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi', 1, 'jpy')]) tx_hex = private_key.sign_transaction(prepared) initial = len(private_key.get_transactions()) current = initial tries = 0 NetworkAPI.broadcast_tx_testnet(tx_hex) while tries < 15: # pragma: no cover current = len(private_key.get_transactions()) if current > initial: break time.sleep(5) tries += 1 assert current > initial
def send(self, outputs, fee=None, leftover=None, combine=True, message=None, unspents=None): """Creates a signed P2PKH transaction and attempts to broadcast it on the testnet blockchain. This accepts the same arguments as :func:`~lit.PrivateKeyTestnet.create_transaction`. :param outputs: A sequence of outputs you wish to send in the form ``(destination, amount, currency)``. The amount can be either an int, float, or string as long as it is a valid input to ``decimal.Decimal``. The currency must be :ref:`supported <supported currencies>`. :type outputs: ``list`` of ``tuple`` :param fee: The number of satoshi per byte to pay to miners. By default Lit will poll `<https://bitcoinfees.earn.com>`_ and use a fee that will allow your transaction to be confirmed as soon as possible. :type fee: ``int`` :param leftover: The destination that will receive any change from the transaction. By default Lit will send any change to the same address you sent from. :type leftover: ``str`` :param combine: Whether or not Lit should use all available UTXOs to make future transactions smaller and therefore reduce fees. By default Lit will consolidate UTXOs. :type combine: ``bool`` :param message: A message to include in the transaction. This will be stored in the blockchain forever. Due to size limits, each message will be stored in chunks of 40 bytes. :type message: ``str`` :param unspents: The UTXOs to use as the inputs. By default Lit will communicate with the testnet blockchain itself. :type unspents: ``list`` of :class:`~bit.network.meta.Unspent` :returns: The transaction ID. :rtype: ``str`` """ tx_hex = self.create_transaction( outputs, fee=fee, leftover=leftover, combine=combine, message=message, unspents=unspents ) NetworkAPI.broadcast_tx_testnet(tx_hex) return calc_txid(tx_hex)