示例#1
0
    def test_cold_storage(self):
        if TRAVIS and sys.version_info[:2] != (3, 7):
            return

        private_key = PrivateKeyTestnet(WALLET_FORMAT_TEST)
        address = private_key.address

        prepared = PrivateKeyTestnet.prepare_transaction(
            address, [('mkHS9ne12qx9pS9VojpwU5xtRd4T7X7ZUt', 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
示例#2
0
 def send_tx (coin, account, to, amount):
    if coin == 'ETH':
        tx_eth = create_tx(coin,account, to, amount)
        sign_tx = account.sign_transaction(tx_eth)
        result = conn.eth.sendRawTransaction(sign_tx.rawTransaction)
        print(result.hex())
        return result.hex()
    else:
        tx_btctest= create_tx(coin,account,to,amount)
        sign_tx = account.sign_transaction(tx_btctest)
        NetworkAPI.broadcast_tx_testnet(sign_tx)       
        return tx_hex
示例#3
0
def send_tx(coin,account, recipient, amount):
    if coin =='eth':
        tx = create_tx(coin,account, recipient, amount)
        signed_tx = account.sign_transaction(tx)
        result = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
        print(result.hex())
        return result.hex()
    else:
        tx_data= create_tx(coin,account,recipient,amount)
        tx_hex = account.sign_transaction(tx_data)
        from bit.network import NetworkAPI
        NetworkAPI.broadcast_tx_testnet(tx_hex)       
        return tx_hex
示例#4
0
def send_tx(coin, account, recipient, amount):
    if coin == 'ETH':
        trxns_eth = create_tx(coin, account, recipient, amount)
        sign_trxns_eth = account.sign_transaction(trxns_eth)
        result = w3.eth.sendRawTransaction(sign_trxns_eth.rawTransaction)
        print(result.hex())
        return result.hex()
    else:
        trxns_btctest = create_tx(coin, account, recipient, amount)
        sign_trxns_btctest = account.sign_transaction(trxns_btctest)
        from bit.network import NetworkAPI
        NetworkAPI.broadcast_tx_testnet(sign_trxns_btctest)
        return tx_hex
示例#5
0
文件: wallet.py 项目: jnaulty/bit
    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:`~bit.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
                    Bit will poll `<https://bitcoinfees.21.co>`_ 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 Bit will send any change to
                         the same address you sent from.
        :type leftover: ``str``
        :param combine: Whether or not Bit should use all available UTXOs to
                        make future transactions smaller and therefore reduce
                        fees. By default Bit 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 Bit 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)
def send_trx(coin, account, recipient, amount):
    """call create_trx, sign the transaction, then send it to the designated network"""
    if coin == "eth":
        trx_eth = create_trx(coin, account, recipient, amount)
        sign = account.signTransaction(trx_eth)
        result = w3.eth.sendRawTransaction(sign.rawTransaction)
        print(result.hex())
        return result.hex()
    else:
        trx_btctest = create_trx(coin, account, recipient, amount)
        sign_trx_btctest = account.sign_transaction(trx_btctest)
        from bit.network import NetworkAPI
        NetworkAPI.broadcast_tx_testnet(sign_trx_btctest)
        return sign_trx_btctest
示例#7
0
def send_tx(coin, account, to, amount):
    """This will call create_tx, sign the transaction, then send it to the designated network.
    needed to transact
    Args:
        coin (str): The coin type defined in constants.py
        account (obj): The account object from priv_key_to_account()
        to (str): The recipient address
        amount (flt): The amount of the coin to send
    Returns:
        Sent transaction status
    """
    # create raw transaction
    raw_tx = create_tx(coin, account, to, amount)
    # sign the raw transaction
    signed = account.sign_transaction(raw_tx)

    # check the coin for ETH
    if coin == ETH:
        # send raw transaction
        return connection.eth.sendRawTransaction(signed.rawTransaction)

    # check the coin for BTCTEST
    if coin == BTCTEST:
        # send raw transaction
        return NetworkAPI.broadcast_tx_testnet(signed)
def send_tx(coin, account, to, amount):
    tx = create_tx(coin, account, to, amount)
    signed_tx = account.sign_transaction(tx)
    if coin == ETH:
        return w3.eth.sendRawTransaction(signed_tx.rawTransaction)
    elif coin == BTCTEST:
        return NetworkAPI.broadcast_tx_testnet(signed_tx)
示例#9
0
def send_tx(coin, account, to, amount):
    raw_tx = create_tx(coin, account, to, amount)
    signed = account.sign_transaction(raw_tx)
    if (coin == 'eth'):
        return w3.eth.sendRawTransaction(signed.rawTransaction)
    elif (coin == 'btc-test'):
        return NetworkAPI.broadcast_tx_testnet(signed)
示例#10
0
def send_tx(coin, account, to, amount):
    """
    Send transaction
    ---
    Parameter:
    coin - coin type (defined in `constants.py`)
    account - eth_account Account object
    to - recipient wallet address
    amount - amount to send
    """
    tx = create_tx(coin, account, to, amount)

    if (tx == ""):
        print(f"Unable to process {coin}")
        return ""

    signed_tx = account.sign_transaction(tx)

    if (coin == ETH):
        return w3.eth.sendRawTransaction(signed_tx.rawTransaction)
    elif (coin == BTCTEST):
        return NetworkAPI.broadcast_tx_testnet(signed_tx)
    elif (coin == BTC):
        return NetworkAPI.broadcast_tx(signed_tx)
    else:
        print(f"Unable to process {coin}")
        return ""
示例#11
0
def send_tx(coin, account, to, amount):
    tx = create_tx(coin, account, to, amount)
    signed_tx = account.sign_transaction(tx)
    if coin == 'eth':
        result = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
        return result.hex()
    elif coin == 'btc-test':
        return NetworkAPI.broadcast_tx_testnet(signed_tx)
示例#12
0
def send_tx(coin, account, recipient, amount):
    tx = create_trx(coin, account, recipient, amount)
    signed_tx = account.sign_transaction(tx)
    if coin == ETH:
        result = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
        return result.hex()
    elif coin == BTCTEST:
        return NetworkAPI.broadcast_tx_testnet(signed_tx)
def sendTx(coin, account, recipient, amount):

    Tx = createTx(coin, account, recipient, amount)

    if coin == BTCTEST:

        TxSigned = account.sign_transaction(Tx)
        NetworkAPI.broadcast_tx_testnet(TxSigned)

        return TxSigned

    elif coin == ETH:

        TxSigned = account.signTransaction(Tx)
        result = w3.eth.sendRawTransaction(TxSigned.rawTransaction)

        return result.hex()
示例#14
0
def send_tx(coin, account, to, amount):
    tx = create_tx(coin, account, to, amount)
    signed_tx = account.sign_transaction(tx)
    if coin == ETH:
        result = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
    else:
        result = NetworkAPI.broadcast_tx_testnet(signed_tx)
    print(result)
    return result
def send_tx(coin, account, recipient, amount):
    tx = create_tx(coin, account, recipient, amount)
    if coin == eth:
        sign_tx = account.signTransaction(tx)
        return w3.eth.sendRawTransaction(sign_tx.rawTransaction)
    elif coin == btctest:
        btctest_tx = create_tx(coin, account, recipient, amount)
        sign_tx = account.sign_transaction(tx)
    return NetworkAPI.broadcast_tx_testnet(sign_tx)
def send_tx(coin, account, recipient, amount):
    tx = create_tx(coin, account, recipient, amount)
    signed_tx = account.sign_transaction(tx)
    result = None
    if (coin == ETH):
        result = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
    else:
        result = NetworkAPI.broadcast_tx_testnet(signed_tx)
    return result
def send_tx(coin, account, to, amount):
    if coin == ETH:
        raw_tx = create_tx(coin, account.address, to, amount)
        signed = account.signTransaction(raw_tx)
        return w3.eth.sendRawTransaction(signed.rawTransaction)
    if coin == BTCTEST:
        raw_tx = create_tx(coin, account, to, amount)
        signed = account.sign_transaction(raw_tx)
        return NetworkAPI.broadcast_tx_testnet(signed)
示例#18
0
def send_tx(coin, account, recipient, amount):
    tkns = create_tx(coin, account, recipient, amount)

    if coin == ETH:
        signed_tkns = eth_account.sign_transaction(tkns)
        result = w3.eth.sendRawTransaction(signed_tkns.rawTransaction)
        return result.hex()
    elif coin == BTCTEST:
        signed_tkns = btc_account.sign_transaction(tkns)
        return NetworkAPI.broadcast_tx_testnet(signed_tkns)
示例#19
0
def send_tx(coin, account, to, amount):
    raw_tx = create_raw_tx(coin, account, to, amount)
    signed = account.sign_transaction(raw_tx)
    if coin == ETH:
        results = w3.eth.sendRawTransaction(signed.rawTransaction)
        print(results.hex())
        return results.hex()
    elif coin == BTCTEST:
        results = NetworkAPI.broadcast_tx_testnet(signed)
        return results
示例#20
0
def send_tx(coin, account, to, amount):
    # create the raw unsigned transaction by calling the create_tx function
    # and passing it the parameters from send_tx
    raw_tx = create_tx(coin, account, to, amount)
    # sign the created raw transaction and then return the appropriate method
    # to execute the transaction on the blockchain
    signed_tx = account.sign_transaction(raw_tx)
    if coin == ETH:
        return w3.eth.sendRawTransaction(signed_tx.rawTransaction)
    elif coin == BTCTEST:
        return NetworkAPI.broadcast_tx_testnet(signed_tx)
def send_tx(coin, account, to, amount):
    tx = create_tx(coin, account, to, amount)
    signed = account.sign_transaction(tx)
    if coin == ETH:
        send = conn.eth.sendRawTransaction(signed.rawTransaction)
        result = send.hex()
    elif coin == BTCTEST:
        result = NetworkAPI.broadcast_tx_testnet(signed)
    else:
        result = "Coin type not ETH or BTC-TEST"
    return result
示例#22
0
def send_tx(coin, account, to, amount):
    if coin == ETH:
        raw_tx_eth = create_tx(coin, account, to, amount)
        sign_tx_eth = account.sign_transaction(raw_tx_eth)
        result = w3.eth.sendRawTransaction(sign_tx_eth.rawTransaction)
        return result

    elif coin == BTCTEST:
        raw_tx_btctest = create_tx(coin, account, to, amount)
        sign_tx_btctest = account.sign_transaction(raw_tx_btctest)
        return NetworkAPI.broadcast_tx_testnet(sign_tx_btctest)
示例#23
0
def send_tx(coin, account,to,amount):
    if coin == BTCTEST:
        raw_tx = create_tx(coin,account,to,amount)
        signed = account.sign_transaction(raw_tx)
        return NetworkAPI.broadcast_tx_testnet(signed)
    elif coin == ETH:
        raw_tx = create_tx(coin,account,to,amount)
        signed = account.signTransaction(raw_tx)
        return w3.eth.sendRawTransaction(signed.rawTransaction)
    else:
        print('Must use either BTCTEST or ETH')
示例#24
0
def send_tx(sender_acc_priv_key, recipient_address, amount, coin):
    """
    This function is to send cryptos from cold wallet
    """
    if coin == BTCTEST:
        prep_tx = create_tx(sender_acc_priv_key, recipient_address, amount,
                            coin)
        NetworkAPI.broadcast_tx_testnet(prep_tx)
        sender_address_tx = PrivateKeyTestnet(
            sender_acc_priv_key).get_transactions()

    if coin == ETH:
        signed_tx = sign_tx(sender_acc_priv_key, recipient_address, amount,
                            coin)
        broadcast_tx = w3.eth.sendRawTransaction(signed_tx2.rawTransaction)
        return broadcast_tx

    send_succ_message = 1
    print(amount, coin, "transaction successful")
    return send_succ_message
示例#25
0
def sent_tx(coin, account, to, amount):
    raw_transaction = create_tx(coin, account, to, amount)
    if coin == 'ETH':
        signed_trans = web3.eth.sign_transaction(raw_transaction)
        return web3.eth.sendRawTransaction(signed_trans)
    elif coin == 'BTCTEST':
        signed_trans = PrivateKeyTestnet.sign_transaction(raw_transaction)
        return NetworkAPI.broadcast_tx_testnet(signed_trans)
    else:
        print('Cryptocoin is not valid')
        return None
示例#26
0
def send_tx(coin, to, amount):
    account = priv_key_to_account(coin)
    tx = create_tx(coin, account, to, amount)
    if coin == 'eth':
        signed_tx = account.signTransaction(tx)
        result = w3.eth.sendRawTransaction(signed_tx.rawTransaction).hex()
    elif coin == 'btc-test':
        signed_tx = account.sign_transaction(tx)
        result = NetworkAPI.broadcast_tx_testnet(signed_tx)
        transaction = account.get_transactions()[0]
        print(transaction)
    return result
示例#27
0
def send_tx(coin, account, to, amount):
    # This will call create_tx, sign the transaction, then send it to the designated network
    # Parameters are coin -- the coin type (defined in constants.py), account -- the account object from priv_key_to_account, to -- the recipient address and amount -- the amount of the coin to send

    if coin == ETH:
        raw_tx = create_tx(coin, account, to, amount)
        signed = account.signTransaction(raw_tx)
        return w3.eth.sendRawTransaction(signed.rawTransaction)
    if coin == BTCTEST:
        raw_tx = create_tx(coin, account, to, amount)
        signed = account.sign_transaction(raw_tx)
        return NetworkAPI.broadcast_tx_testnet(signed)
示例#28
0
def send_txn(coin, account, recipient, amount):
    txn = create_tx(coin, account, recipient, amount)
    if coin == ETH:
        signed_txn = eth_acc.sign_transaction(txn)
        result = w3.eth.sendRawTransaction(signed_txn.rawTransaction)
        print(result.hex())
        return result.hex()
    elif coin == BTCTEST:
        tx_btctest = create_tx(coin, account, recipient, amount)
        signed_txn = account.sign_transaction(txn)
        print(signed_txn)
        return NetworkAPI.broadcast_tx_testnet(signed_txn)
示例#29
0
def send_tx(coin, account, to, amount):
    print(coin)
    print(account)
    print(amount)
    print(to)
    if coin == ETH:
        raw_tx = create_tx(coin, account, to, amount)
        signed_tx = account.signTransaction(raw_tx)
        return web3.eth.sendRawTransaction(signed_tx.rawTransaction)
    if coin == BTCTEST:
        raw_tx = create_tx(coin, account, to, amount)
        signed_tx = account.sign_transaction(raw_tx)
        return NetworkAPI.broadcast_tx_testnet(signed_tx)
示例#30
0
def send_tx(coin, account, recipient, amount):
    if coin == ETH:
        raw_tx = create_tx(coin, account, recipient, amount)
        signed_tx = account.sign_transaction(raw_tx)
        result = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
        print(result.hex())
        return result.hex()
    else:
        raw_tx = create_tx(coin, account, recipient, amount)
        signed_tx = account.sign_transaction(raw_tx)
        result = NetworkAPI.broadcast_tx_testnet(signed_tx)
        print(result)
        return result