pik / pypayd

a small daemon for processing bitcoin payments
MIT License
5 stars 4 forks source link

Wallet generation #7

Closed ser closed 9 years ago

ser commented 9 years ago

Hi, I'm installing the whole environment from scratch, to be sure everything is clean.

First problem - I'm not able to generate a wallet:

$ python pypayd.py wallet --from-mnemonic "cigarette add choice joke guess process blood freak rise favorite write pen" --mnemonic-type="electrumseed" --to-file="payment_wallet.txt" --encrypt-pw="foobar"
Loading config settings...
Wallet loaded: tpubD6NzVbkrYhZ4X7VCD5BSWE6nkDvU4c1cLDzVZT1RhXEkBYMh2f74RXb76bRfPQcR2EqDDPewP1B1jCFqAUSzqww22qeg9e5Kw9ZPPH61zxF
Keypath: 0/0/1
Traceback (most recent call last):
  File "pypayd.py", line 164, in <module>
    pypay_wallet.toEncryptedFile(password = args.encrypt_pw, file_name = (args.to_file or config.DEFAULT_WALLET_FILE), store_private = args.output_private, force=args.overwrite)
  File "/home/ser/pypayd/src/wallet.py", line 110, in toEncryptedFile
    data = simplecrypt.encrypt(password, json_for_wallet(store_private))
NameError: name 'json_for_wallet' is not defined
pik commented 9 years ago

Ah yeah sorry, I made some changes and forgot to push them upstream (the --required-only tests which I run on my work computer don't test actions which require simplecrypt since I've actually been unable to get pycrypto to build on OS X). It should be fine now.

Also I've made it possible to use a non-encrypted file for a wallet (which should be quite safe with chmod 400 as long as you're only using the public master key).

ser commented 9 years ago

Yes, the wallet was generated correctly now, it's a really good idea to make it unencrypted.

But now it does not work in pypayd:

$ python pypayd.py --server wallet --from-file="counterwallet.pypayd"
Loading config settings...
Traceback (most recent call last):
  File "pypayd.py", line 118, in <module>
    pypay_wallet = wallet.PyPayWallet.fromEncryptedFile(password= (args.decrypt_pw or config.DEFAULT_WALLET_PASSWORD), file_name=os.path.join(config.DATA_DIR, args.from_file))
  File "/home/ser/pypayd/src/wallet.py", line 52, in fromFile
    data = cls._decryptFile(password, data)
  File "/home/ser/pypayd/src/wallet.py", line 61, in _decryptFile
    return simplecrypt.decrypt(password, data).decode('utf-8')
  File "/usr/lib/python3.4/site-packages/simplecrypt/__init__.py", line 64, in decrypt
    _assert_header_prefix(data)
  File "/usr/lib/python3.4/site-packages/simplecrypt/__init__.py", line 100, in _assert_header_prefix
    raise DecryptionException('Data passed to decrypt were not generated by simple-crypt (bad header).')
simplecrypt.DecryptionException: Data passed to decrypt were not generated by simple-crypt (bad header).
pik commented 9 years ago

@ser I switched to fromFile by default and it wasn't using a decrypt-password if it was not specified with --decrypt-pw and ignored the one set in pypayd.conf. Should be fixed now.