importprivkey BTC RPC is not importing wallet address created with bitcoinaddress Library

69 Views Asked by At

Importprivkey is not importing the address after too much execution it's returning a response of timeout. tried the same command in bitcoin-cli and it's working perfectly. Looking for a solution. Thanks

def send_amount(sender_private_key, sender_public_key, sender_wallet_address, receiver_wallet_address, amount): try:

    wallet_info = host.call('getwalletinfo')   #importing address
    if host.call('getwalletinfo').get('scanning'):
        host.call('abortrescan')
    import_wallet_through_private_key = host.call('importprivkey', sender_private_key, "false")   #importing address
    get_last_transaction = host.call('listunspent', 0, 10, ["msMiVrsLaJq3X15w2cUsnSd2Abs7Nf2Xm7"])   #Getting last transaction of sender
    arg1 = [
        {
            "txid": get_last_transaction[0].get("txid"),
            "vout": get_last_transaction[0].get("vout")
        }
    ]
    arg2 = {
            "tb1qz4kdh9h5xfx4h75r3x6r9hz9y2mmd5kveg83fm": 0.000008,
        }

    hexstring = host.call('createrawtransaction', arg1, arg2)                #for creating raw transaction
    sign_transaction = host.call('signrawtransactionwithkey', hexstring, [sender_private_key])       #for signing a transaction
    transaction_id = host.call('sendrawtransaction', sign_transaction.get("hex"))

    transaction_id = host.call('sendtoaddress', 'msMiVrsLaJq3X15w2cUsnSd2Abs7Nf2Xm7', float(amount))

    return transaction_id

except Exception as Msg:
    raise Exception(str(Msg))
0

There are 0 best solutions below