1200wd / bitcoinlib

Bitcoin and other Cryptocurrencies Library for Python. Includes a fully functional wallet, Mnemonic key generation and management and connection with various service providers to receive and send blockchain and transaction information.
http://bitcoinlib.readthedocs.io/
GNU General Public License v3.0
615 stars 204 forks source link

Can't send bitcoin to myself #266

Closed crazypon closed 2 years ago

crazypon commented 2 years ago
def send_to_myself(wallet: Wallet):
    config = configparser.ConfigParser()
    config.read("bot.ini")
    wallet.transactions_update()
    wallet_info = wallet.as_dict()
    main_wallet = config["payments"]["wallet_address"]
    wallet.utxos_update(networks="testnet")
    wallet.balance_update_from_serviceprovider(network="testnet")
    wallet.get_keys()
    wallet.info()
    wallet.scan()
    wallet.transactions_update()
    wallet.transactions_update_confirmations()
    print(wallet.utxos())
    transaction_hash = wallet.send_to(main_wallet, "0.00030000 TBTC", fee=1024)
    print(transaction_hash.info())
    transaction_hash.update_totals()

    return transaction_hash

The transaction info() output:

Transaction fbf725397ecb40474538cca6bc739d8bedb2b87fc77dcd5b08a224be606174ea Date: None Network: testnet Version: 1 Witness type: legacy Status: new Verified: True Inputs

I have waited some. But nothing happened. Could you help me please?

mccwdev commented 2 years ago

You need to push the transaction to the network first. So send it right away with the offline=False parameter, or check it first and then use the send() method.

t = wallet.send_to(main_wallet, "0.00030000 TBTC", fee=1024, offline=False)
# or
t.send()
crazypon commented 2 years ago

@mccwdev Thank you very much!!!