Steem Python BIP38 Wallet Error with Fix

in steemdev •  7 years ago  (edited)

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

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

100% upvote for support... great information.

had same problem, pull request submitted https://github.com/steemit/steem-python/pull/245

EDIT: Thanks for not telling me to use beempy!!

A560CEDF-37CE-4AFA-A241-A59A98253AD2.png

Wow, thanks it helped! Not sure why they release stuff with errors? lol
2019-06-09 14:59:17 ☆ nickademous in ~
± |master ↑1 ↓2 S:387 U:367 ?:474 ✗| → steempy importaccount coininstant
Account Passphrase:
Importing active key!
Passphrase:
Importing posting key!
Importing memo key!