Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange Error #5

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
38 changes: 14 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Preface
============
This is a fork of https://github.com/Multibit-Legacy/read-multibit-wallet-file that includes
a fix for the `TypeError: Cannot read property 'fromPrivate' of undefined` error (and maybe a few others) mentioned in [this thread](https://github.com/Multibit-Legacy/read-multibit-wallet-file/pull/1). Although I have a [pull request](https://github.com/Multibit-Legacy/read-multibit-wallet-file/pull/2) pending with this fix, the original project seems to be abandoned. Everything below is from the original project's `readme` except for where I renamed `mbexport` to `mbexport-rd` (as that is the npm package with this fix).

---
---

A simple command line tool that exports the private Keys from a Multibit
wallet file. The reason this tool exists is because Multibit is out of
date and has known bugs. Exporting the private keys or wallet words from
Expand All @@ -9,7 +17,7 @@ Installation
1. Install node version 6 or higher. You can get it from
https://nodejs.org/en/download/.
2. Open a command prompt and install this utility:
```npm install -g mbexport```
```npm install -g mbexport-rd```

Now you are ready to export the private keys from your wallet.

Expand Down Expand Up @@ -49,21 +57,21 @@ Exporting Your Keys
===================
Open a command prompt and type the following command:

```mbexport <path-to-wallet-file>```
```mbexport-rd <path-to-wallet-file>```

For example, if you are using Multibit HD on MacOS, you would type
something like:

```mbexport ~/Library/Application\ Support/MultiBitHD/mbhd-aff7bb4a-8a5d9101-e7e97974-f999c7fb-53795c76/mbhd.wallet.aes```
```mbexport-rd ~/Library/Application\ Support/MultiBitHD/mbhd-aff7bb4a-8a5d9101-e7e97974-f999c7fb-53795c76/mbhd.wallet.aes```

TIP: If you can find the wallet file in the file explorer application,
you can type ```mbexport ``` in the command prompt, then drag the file
you can type ```mbexport-rd ``` in the command prompt, then drag the file
from explorer to the command prompt. It should fill in the long file
name for you.

When you run ```mbexport```, it will ask you to enter the passphrase
When you run ```mbexport-rd```, it will ask you to enter the passphrase
for your wallet. Once you do will list any private keys and mnemonic
seeds that it finds in the file. If you run ```mbexport``` on a
seeds that it finds in the file. If you run ```mbexport-rd``` on a
Multibit Classic file, the output will look simliar to this:

```
Expand All @@ -82,24 +90,6 @@ Enter your passphrase: ***
measure swim globe radio reunion awful reflect tail produce treat cluster spot
```

Multibit (Classic)
==================

Importing to Electrum
---------------------
Details coming soon

MultibitHD
==========

Importing to Electrum
---------------------
Details coming soon

Importing to Bread Wallet
-------------------------
Details coming soon


````
This tool and these instructions are distributed under the MIT License
Expand Down
10 changes: 5 additions & 5 deletions build/aes-cbc-decrypter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
var scrypt_encryption_key_1 = require("./scrypt-encryption-key");
var crypto = require("crypto");
var ByteBuffer = require("bytebuffer");
var FRAGMENT_SIZE = 16;
var Decrypter = (function () {
function Decrypter(key) {
this.key = key;
Expand All @@ -21,9 +20,11 @@ var Decrypter = (function () {
Decrypter.prototype.decrypt = function (data, iv) {
return this.initialize(iv)
.then(function (aesCbc) {
var mainBuffer = aesCbc.update(Buffer.from(data.toBuffer()));
var finalBuffer = aesCbc.final();
var decrypted = Buffer.concat([
aesCbc.update(Buffer.from(data.toBuffer())),
aesCbc.final()
mainBuffer,
finalBuffer
]);
return ByteBuffer.wrap(decrypted);
});
Expand All @@ -32,8 +33,7 @@ var Decrypter = (function () {
return this.key.keyPromise
.then(function (key) {
return crypto.createDecipheriv('aes-256-cbc', key.toBuffer(), iv.toBuffer());
})
.catch(function () { return console.log('whoa. fail.'); });
});
};
return Decrypter;
}());
Expand Down
23 changes: 18 additions & 5 deletions build/mbexport → build/mbexport-rd
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ var aes_cbc_decrypter_1 = require("./aes-cbc-decrypter");
var fs = require("fs");
var bcoin = require("bcoin");
var prompt = require('prompt');
var FIXED_IV = ByteBuffer.wrap(new Uint8Array([
0xa3, 0x44, 0x39, 0x1f, 0x53, 0x83, 0x11, 0xb3,
0x29, 0x54, 0x86, 0x16, 0xc4, 0x89, 0x72, 0x3e
]));
prompt.message = '';
prompt.delimiter = '';
var Wallet = require('../build/wallet').wallet.Wallet;
Expand Down Expand Up @@ -41,14 +45,23 @@ try {
}
catch (e) {
console.log('MultibitHD wallet opened');
var decrypter_1;
walletPromise = getPassphrase()
.then(function (passphrase) {
return aes_cbc_decrypter_1.Decrypter
.factory(passphrase)
.decrypt(pb.slice(16), pb.slice(0, 16));
decrypter_1 = aes_cbc_decrypter_1.Decrypter
.factory(passphrase);
pb.reset();
return decrypter_1.decrypt(pb.slice(16), pb.slice(0, 16))
.then(function (payload) {
return Wallet.decode(payload);
});
})
.then(function (payload) {
return Wallet.decode(payload);
.catch(function (e) {
pb.reset();
return decrypter_1.decrypt(pb, FIXED_IV)
.then(function (payload) {
return Wallet.decode(payload);
});
});
}
walletPromise.then(function (wallet) {
Expand Down
23 changes: 18 additions & 5 deletions build/mbexport.js → build/mbexport-rd.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ var aes_cbc_decrypter_1 = require("./aes-cbc-decrypter");
var fs = require("fs");
var bcoin = require("bcoin");
var prompt = require('prompt');
var FIXED_IV = ByteBuffer.wrap(new Uint8Array([
0xa3, 0x44, 0x39, 0x1f, 0x53, 0x83, 0x11, 0xb3,
0x29, 0x54, 0x86, 0x16, 0xc4, 0x89, 0x72, 0x3e
]));
prompt.message = '';
prompt.delimiter = '';
var Wallet = require('../build/wallet').wallet.Wallet;
Expand Down Expand Up @@ -41,14 +45,23 @@ try {
}
catch (e) {
console.log('MultibitHD wallet opened');
var decrypter_1;
walletPromise = getPassphrase()
.then(function (passphrase) {
return aes_cbc_decrypter_1.Decrypter
.factory(passphrase)
.decrypt(pb.slice(16), pb.slice(0, 16));
decrypter_1 = aes_cbc_decrypter_1.Decrypter
.factory(passphrase);
pb.reset();
return decrypter_1.decrypt(pb.slice(16), pb.slice(0, 16))
.then(function (payload) {
return Wallet.decode(payload);
});
})
.then(function (payload) {
return Wallet.decode(payload);
.catch(function (e) {
pb.reset();
return decrypter_1.decrypt(pb, FIXED_IV)
.then(function (payload) {
return Wallet.decode(payload);
});
});
}
walletPromise.then(function (wallet) {
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ gulp.task('typescript', ['wallet.d.ts'], function () {
gulp.task('build', ['typescript', 'protocolBuffers'], function() {
return gulp.src('build/mbexport.js')
.pipe(chmod(0o755))
.pipe(rename('mbexport'))
.pipe(rename('mbexport-rd'))
.pipe(gulp.dest('build'));
});

Expand Down
Loading