jackjack-jj / pywallet

bitcoin wallet importer/exporter
497 stars 347 forks source link

ERROR parsing wallet.dat, type setting #27

Closed andreashb2 closed 2 years ago

andreashb2 commented 3 years ago

This is the command I run: python pywallet.py --wallet=/home/user/Desktop/wallet.dat --dumpwallet

This is the error I get: Traceback (most recent call last): File "pywallet.py", line 2273, in parse_wallet d['value'] = parse_setting(d['setting'], vds) File "pywallet.py", line 1489, in parse_setting return deserialize_CAddress(d) File "pywallet.py", line 1471, in deserialize_CAddress return d['ip']+":"+str(d['port']) File "pywallet.py", line 109, in getitem return super(Bdict, self).getitem(bytes_to_str(k)) KeyError: u'ip' ERROR parsing wallet.dat, type setting key data: setting addrIncoming key data in hex: XX (censored) value data in hex: XX (censored)

3 files are made on my desktop: db.001 db.002 __db.003 None can be opened.

wallet.dat is a Litecoin wallet backup (probably from litecoin-qt) from 2013 with a size of 88kb. I have python version 2.7.17. My goal is to extract the private keys

jake01-dev commented 3 years ago

I believe I'm running into the exact same issue. I am trying to dump a bitcoin wallet from 2013.

'ecdsa' package is not installed, pywallet won't be able to sign/verify messages Traceback (most recent call last): File "/Users/jtroy/Documents/BTC Data/pywallet-master/pywallet.py", line 2273, in parse_wallet d['value'] = parse_setting(d['setting'], vds) File "/Users/jtroy/Documents/BTC Data/pywallet-master/pywallet.py", line 1489, in parse_setting return deserialize_CAddress(d) File "/Users/jtroy/Documents/BTC Data/pywallet-master/pywallet.py", line 1471, in deserialize_CAddress return d['ip']+":"+str(d['port']) File "/Users/jtroy/Documents/BTC Data/pywallet-master/pywallet.py", line 109, in getitem return super(Bdict, self).getitem(bytes_to_str(k)) KeyError: u'ip' ERROR parsing wallet.dat, type setting key data: setting addrIncoming key data in hex: XXXX value data in hex: XXXX

Anyone have any luck with this? Jake

banzo commented 3 years ago

Commenting line 1464 and returning "0.0.0.0:0" at line 1471 removes the error https://github.com/jackjack-jj/pywallet/blob/master/pywallet.py#L1464-L1471

Now I got "error code: 1015" in the json output balance fields, which seems to indicate rate limiting issues but might be caused by the hack above.

llamasoft commented 3 years ago

I found a lazier fix that won't cause errors: just don't parse the settings. Add a "continue" as the first line of the elif type == b"setting": block here: https://github.com/jackjack-jj/pywallet/blob/c88faf86c9b57859af9ec2b9836da85a327e3b02/pywallet.py#L2271

jake01-dev commented 3 years ago

@llamasoft - thank you, this solution worked for me.

Fredisaurus commented 3 years ago

Hi there

I believe I'm running into the exact same issue. I am trying to dump a bitcoin wallet from 2013.

'ecdsa' package is not installed, pywallet won't be able to sign/verify messages Traceback (most recent call last): File "/Users/jtroy/Documents/BTC Data/pywallet-master/pywallet.py", line 2273, in parse_wallet d['value'] = parse_setting(d['setting'], vds) File "/Users/jtroy/Documents/BTC Data/pywallet-master/pywallet.py", line 1489, in parse_setting return deserialize_CAddress(d) File "/Users/jtroy/Documents/BTC Data/pywallet-master/pywallet.py", line 1471, in deserialize_CAddress return d['ip']+":"+str(d['port']) File "/Users/jtroy/Documents/BTC Data/pywallet-master/pywallet.py", line 109, in getitem return super(Bdict, self).getitem(bytes_to_str(k)) KeyError: u'ip' ERROR parsing wallet.dat, type setting key data: setting addrIncoming key data in hex: XXXX value data in hex: XXXX

Anyone have any luck with this? Jake

Hi there!

I have the exact same issue here. I have spent 3 days doing my own research online trying to figure out how to decrypt this statement alone:

"Add a "continue" as the first line of the elif type == b"setting": block here:" located at Line 2271"

I have watched countless of YouTube videos on how to use 'continue'. Also tried out using the process of elimination by relocating the position of the word 'continue'. (Like placing at the top, bottom, beside it, to the left, to the right... You get the point.) Just so I don't look like a sore thumb asking for the same help when the formula was already given and approved with like 2 Thumbs Up? But man, I am truly sorry. I could not to understand. I have zero knowledge on coding.

Can someone help me out with an easier step-by-step guide/walkthrough?

Appreciated.

@llamasoft @jake01-dev @nicocesar @banzo @andreashb2

nicocesar commented 3 years ago

@Fredisaurus what a good time to be alive! this is my diff:

diff --git a/pywallet.py b/pywallet.py
old mode 100644
new mode 100755
index cf24ea0..7d021d8
--- a/pywallet.py
+++ b/pywallet.py
@@ -2269,8 +2269,9 @@ def parse_wallet(db, item_callback):
                        elif type == b"minversion":
                                d['minversion'] = vds.read_uint32()
                        elif type == b"setting":
-                               d['setting'] = kds.read_string()
-                               d['value'] = parse_setting(d['setting'], vds)
+                               continue
+                               #d['setting'] = kds.read_string()
+                               #d['value'] = parse_setting(d['setting'], vds)
                        elif type == b"key":
                                d['public_key'] = kds.read_bytes(kds.read_compact_size())
                                d['private_key'] = vds.read_bytes(vds.read_compact_size())

If it works and you want to try out that the transfers work correctly here is an destination address you can use: 3N9GTTtD4jWGrimTg7gujNHS1f146W7Qxv

Cheers!

wschoot commented 3 years ago

I found a lazier fix that won't cause errors: just don't parse the settings. Add a "continue" as the first line of the elif type == b"setting": block here:

https://github.com/jackjack-jj/pywallet/blob/c88faf86c9b57859af9ec2b9836da85a327e3b02/pywallet.py#L2271

Thanks, this helped!

erm3nda commented 3 years ago

Commenting line 1464 and returning "0.0.0.0:0" at line 1471 removes the error https://github.com/jackjack-jj/pywallet/blob/master/pywallet.py#L1464-L1471

Now I got "error code: 1015" in the json output balance fields, which seems to indicate rate limiting issues but might be caused by the hack above.

I've tried with sample wallet.dat with several addresss, and totally seems rate limit, because first addresses got solved, but stopped at the 5th/6th address.

jackjack-jj commented 2 years ago

99316a1 should fix that

tepan024 commented 1 year ago

I found a lazier fix that won't cause errors: just don't parse the settings. Add a "continue" as the first line of the elif type == b"setting": block here:

https://github.com/jackjack-jj/pywallet/blob/c88faf86c9b57859af9ec2b9836da85a327e3b02/pywallet.py#L2271

how ? i'm numb with this error, pls help :(