greenaddress / lamassu-greenaddress

Lamassu GreenAddress module
0 stars 0 forks source link

Error "Cannot read property 'sigBytes' of undefined" #1

Closed CrypticaScriptura closed 9 years ago

CrypticaScriptura commented 9 years ago

Excited for the module! Here's what I experienced when running it:

Configured lamassu-greenaddress using the following process: https://gist.github.com/naconner/996ac6aafdba0cc29fda

After starting lamassu-server, logs reveal:

root@lamassu-greenaddress:~# tail -f /var/log/upstart/lamassu-server.log | bunyan
    at loadPlugin (/usr/local/lib/node_modules/lamassu-server/lib/plugins.js:94:12)
    at loadOrConfigPlugin (/usr/local/lib/node_modules/lamassu-server/lib/plugins.js:111:25)
    at Object.configure (/usr/local/lib/node_modules/lamassu-server/lib/plugins.js:140:3)
[2014-09-23T03:13:42.333Z]  INFO: lamassu-server/26181 on lamassu-greenaddress: Version: 1.0.2
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
lamassu-server listening on port 3000 (https)
[2014-09-23T03:13:42.539Z]  INFO: lamassu-server/26181 on lamassu-greenaddress: Git: # @
[2014-09-23T03:13:42.596Z] DEBUG: lamassu-server/26181 on lamassu-greenaddress: polling for rates (Bitpay)

/usr/local/lib/node_modules/lamassu-server/node_modules/lamassu-greenaddress/node_modules/crypto-js/hmac.js:53
                if (key.sigBytes > hasherBlockSizeBytes) {
                       ^
TypeError: Cannot read property 'sigBytes' of undefined
    at Object.C_algo.HMAC.Base.extend.init (/usr/local/lib/node_modules/lamassu-server/node_modules/lamassu-greenaddress/node_modules/crypto-js/hmac.js:53:21)
    at Object.subtype.init (/usr/local/lib/node_modules/lamassu-server/node_modules/lamassu-greenaddress/node_modules/crypto-js/core.js:68:46)
    at Object.C_lib.Base.create (/usr/local/lib/node_modules/lamassu-server/node_modules/lamassu-greenaddress/node_modules/crypto-js/core.js:95:32)
    at Object.C_algo.PBKDF2.Base.extend.compute (/usr/local/lib/node_modules/lamassu-server/node_modules/lamassu-greenaddress/node_modules/crypto-js/pbkdf2.js:75:30)
    at Object.C.PBKDF2 (/usr/local/lib/node_modules/lamassu-server/node_modules/lamassu-greenaddress/node_modules/crypto-js/pbkdf2.js:138:36)
    at BIP39.mnemonicToSeed (/usr/local/lib/node_modules/lamassu-server/node_modules/lamassu-greenaddress/node_modules/bip39/index.js:16:17)
    at Object.config (/usr/local/lib/node_modules/lamassu-server/node_modules/lamassu-greenaddress/lib/index.js:21:29)
    at loadPlugin (/usr/local/lib/node_modules/lamassu-server/lib/plugins.js:94:12)
    at loadOrConfigPlugin (/usr/local/lib/node_modules/lamassu-server/lib/plugins.js:111:25)
    at Object.configure (/usr/local/lib/node_modules/lamassu-server/lib/plugins.js:140:3)

Running lamassu-update-config on a .json to set the current plugin back to another wallet module clears that error in the logs and allows for the machine to progress to Hello/Start once the other wallet's credentials are configured.

greenaddress commented 9 years ago

Thank you for trying to run it!

I get the same error when I don't pass credentials to the plugin. You need to pass a GreenAddress mnemonic for our production server, which means a mnemonic for a wallet registered at https://greenaddress.it/en/wallet/#/create

It can be passed through the 'guid' parameter, which I decided to reuse for compatibility with lamassu-admin. Please let us know if there is a better way to define wallet parameters.

So anyway, you can simply change your greenaddress-settings.json file to include

"guid": "(your mnemonic here)"

line inside the greenaddress key, re-run lamassu-update-config greenaddress-settings.json and it should work.

CrypticaScriptura commented 9 years ago

Thanks for the guidance, @greenaddress

I'm wondering if it's possible to use an encrypted mnemonic as the GUID and Password as the decryption password for that.

In anycase, the GUID field can be starred about by editing wallet.jade.

I've made a few transactions! Two things I noticed:

Despite sending to a GreenAddress wallet, I recevied the error:

ERROR: sending coins: {"name":"InsufficientFunds"}; Trying without instant.

Does there need to be a minimum balance for InstantConfirmation? At the time, the wallet had ~$12 USD.

Also, after two transactions, the machine went to balanceLow until 21 minutes later, when the balance reflected again in the logs. I take this to be because the wallet uses change addresses and does not have enough unspent outputs:

root@lamassu-greenaddress:~# tail -f /var/log/upstart/lamassu-server.log | bunyan
[2014-09-23T16:50:04.260Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:50:06.917Z] DEBUG: collecting balance
[2014-09-23T16:50:06.924Z] DEBUG: polling for rates (Bitpay)
[2014-09-23T16:50:06.969Z] DEBUG: got rates: {"USD":{"currency":"USD","rates":{"ask":396.02,"bid":396.02}}}
[2014-09-23T16:50:07.009Z] DEBUG: Balance update: { transferBalance: { BTC: 2457000 } }
[2014-09-23T16:50:08.975Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:50:13.965Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:50:18.894Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:50:24.185Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:50:29.285Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:50:34.434Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
ERROR: sending coins: {"name":"InsufficientFunds"}; Trying without instant.
[2014-09-23T16:50:35.874Z] DEBUG: collecting balance
[2014-09-23T16:50:35.966Z] DEBUG: Balance update: { transferBalance: { BTC: 503000 } }
[2014-09-23T16:50:39.408Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:50:44.377Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:50:49.032Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:50:54.202Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:50:59.581Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:51:04.207Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:51:06.920Z] DEBUG: collecting balance
[2014-09-23T16:51:06.933Z] DEBUG: polling for rates (Bitpay)
[2014-09-23T16:51:06.989Z] DEBUG: got rates: {"USD":{"currency":"USD","rates":{"ask":396.03,"bid":396.03}}}
[2014-09-23T16:51:07.013Z] DEBUG: Balance update: { transferBalance: { BTC: 503000 } }
[2014-09-23T16:51:09.399Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
ERROR: sending coins: {"name":"InsufficientFunds"}; Trying without instant.
[2014-09-23T16:51:13.494Z] DEBUG: collecting balance
[2014-09-23T16:51:13.585Z] DEBUG: Balance update: { transferBalance: { BTC: 0 } }
[2014-09-23T16:51:14.351Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:51:19.620Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:51:24.736Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:51:29.533Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:51:34.669Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:51:39.698Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:51:44.349Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:51:49.332Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:51:54.874Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:51:59.344Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T16:52:04.361Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[...]
[2014-09-23T17:11:07.129Z] DEBUG: collecting balance
[2014-09-23T17:11:07.154Z] DEBUG: polling for rates (Bitpay)
[2014-09-23T17:11:07.220Z] DEBUG: Balance update: { transferBalance: { BTC: 0 } }
[2014-09-23T17:11:07.222Z] DEBUG: got rates: {"USD":{"currency":"USD","rates":{"ask":394.17,"bid":394.17}}}
[2014-09-23T17:11:07.930Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:11:13.056Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:11:18.053Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:11:23.053Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:11:28.046Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:11:33.060Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:11:38.607Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:11:43.122Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:11:48.101Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:11:53.115Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:11:58.355Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:12:03.552Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:12:07.133Z] DEBUG: collecting balance
[2014-09-23T17:12:07.161Z] DEBUG: polling for rates (Bitpay)
[2014-09-23T17:12:07.203Z] DEBUG: got rates: {"USD":{"currency":"USD","rates":{"ask":394,"bid":394}}}
[2014-09-23T17:12:07.227Z] DEBUG: Balance update: { transferBalance: { BTC: 1933000 } }
[2014-09-23T17:12:08.163Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:12:13.695Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:12:18.451Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:12:23.619Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
[2014-09-23T17:12:28.593Z] DEBUG: poll request from: 68:51:B3:78:BC:F4:45:05:10:C5:6D:B9:50:A2:4A:C3:2F:B2:61:58
greenaddress commented 9 years ago

we don't think it adds any value to have something encrypted stored in the same file with the key to decrypt it

We don't seem to understand what you mean by starred

instant confirmation requires 6 confirmation for the previous output.

the balance shows transactions with at least one confirmation (that is, in the plugin, while in the app it shows all transactions)

CrypticaScriptura commented 9 years ago

I understand there not being an advantage in having an encrypted mnemonic with the key to decrypt it in the same file, if an attacker were to have access to the server. However, since the password field in the future release of the admin will be starred out (replaced by asterisks), an attacker gaining access to the admin would not be able to decrypt it by seeing the encrypted mnemonic alone.

The GUID field can be starred out by a user, just as the current password field can be with:

sed -i 's/input#wallet_password/input(type="password")#wallet_password/'  \
/usr/local/lib/node_modules/lamassu-admin/client/templates/main/wallet.jade

Thanks for the clarification on instant confirmations.

Splitting the "Out of bitcoins" issue to a separate ticket and closing this one: https://github.com/greenaddress/lamassu-greenaddress/issues/2