bitcoinj/bitcoinj — pull request #157 by troggy (2014-08-04 13:17:34+00:00)
Title: Pluggable signers: simple KeyBag signer

First portion of work on pluggable signers.

Introduced transaction signer notion. Instances of TransactionSigner could be added into the wallet, so that they subsequently applied to transaction to complete it.
Existing signing code (Transaction.signInputs) was refactored into KeyBagTransactionSigner, which is always implicitly added to any wallet.

Several things I don't like about proposed design:
1. Every signer has to be accompanied with corresponding WalletExtension implementation, otherwise it would be lost after deserialization. It looks error-prone for me. I think of making TransactionSigner to be WalletExtension itself, so that we could implicitly register new extension in addTransactionSigner method.
2. If signer throws an exception, it is treated as incompatible signer and exception is swallowed. It doesn't look neat, real errors in implementation may be missed. Maybe it worth obliging TransactionSigner to throw some specific exception if it's not compatible?
3. As KeyBagTransactionSigner may be provided with encrypted KeyBag, signer needs a password to decrypt it. I see no way to pass DecryptingKeyBag to signer during construction -- KeyBagTransactionSigner is being constructed on wallet creation when password isn't available. So I'm passing password as an argument for TransactionSigner.signInputs. This does the trick, but used only for KeyBag-aware implementation and thus is polluting method signature.