Steem Python BIP38 Wallet Error with Fix

steem python.jpg
Good evening Steem Scripters,

I had recently exercised what I like to call the nuclear option regarding my Ubuntu virtual machine when I began receiving NoneType errors. In other words, I completely blew away my VM and started from scratch. Well, in retrospect, that may have not been the least painful way I could have addressed the problem but resulted in a couple good things namely the upgrade of my OS and Python. Turns out it was the node that I was connecting that was having issues but that's unimportant now.

What is important is I understand other Steem scripters may be having issues with the libraries and I wanted to share a prospective fix for one that seemed to assist in my issue. I was encountering errors when attempting to add a new key. I received the following error which I just duplicated. (b was a sample bytecode string I had generated but I was receiving the same upon using the related library function)

aes = AES.new(b)
Traceback (most recent call last):
File "stdin", line 1, in module
TypeError: new() missing 1 required positional argument: 'mode'

What was the fix you might ask? It took me a bit of investigating and I came accross the following page with info on the AES module:

https://pythonhosted.org/pycrypto/Crypto.Cipher.AES-module.html

Here is the function:

Details

Notice the "Mode" parameter. Hmmm remember that error?

mode (a MODE_* constant) - The chaining mode to use for encryption or decryption. Default is MODE_ECB.

If we examine the BIP38.py wallet script in the steembase directory, we will notice that the mode argument is absent. What if we were to add it? That's exactly what I did to both the encrypt and decrypt functions. After that, I was able to successful add the key and perform voting operations with python. Here is the line you will need to replace.

aes = AES.new(derived_half2,AES.MODE_ECB)

I will also note that, if my memory serves me, I had encountered issues with the requires file involving versioning of dependences (toml among them I think). If there is demand, I will look into creating an article for that as well.

Please, let me know if this helps you or, if there are any questions, feel free to drop a comment.
Upvote, Resteem, and comment if you want to show some love 💖 and 👀 more!

To tip crypto, you may also use the following addresses:
BTC wallet: 1BKV8gfFbWgeVJVqedsDj9TX9TWGxpCSEh
ETH: 0xaC8920ACaD58C40c46B75E13957605c72770C2Ca
LTC wallet: LfP1he2KyZzGJYXwbSNdfLZ6wUNL71nBvt
DOGE wallet: DNAQbrku7HmxDSX8RayHp6cv4mum5XGERe
DASH wallet: XbfzvP7Jt3LaMe2x1ho97uJp4TdfiZ9C1W
BLK: BBXcqjeqYdREt9ExSN6jduL7kEh6YjY2RF
VRM: VWFPCf7DmHYhQbXtV2SNRdCdo4LkMjFAkR

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now