Wallet throws on missing signature by default

Using dummy sigs by default may be confusing for multi-sig scenarios.
See: https://groups.google.com/forum/#!topic/bitcoinj/PEhZGk3WMxU
This commit is contained in:
Kosta Korenkov
2014-09-05 15:55:54 +07:00
committed by Mike Hearn
parent ae24da4f9c
commit c2d19a31a8
3 changed files with 13 additions and 2 deletions

View File

@@ -3028,10 +3028,10 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
/**
* Specifies what to do with missing signatures left after completing this request. Default strategy is to
* replace missing signatures with dummy sigs ({@link MissingSigsMode#USE_DUMMY_SIG}).
* throw an exception on missing signature ({@link MissingSigsMode#THROW}).
* @see MissingSigsMode
*/
public MissingSigsMode missingSigsMode = MissingSigsMode.USE_DUMMY_SIG;
public MissingSigsMode missingSigsMode = MissingSigsMode.THROW;
/**
* If not null, this exchange rate is recorded with the transaction during completion.

View File

@@ -394,6 +394,7 @@ public class PaymentChannelServerState {
signMultisigInput(tx, Transaction.SigHash.NONE, true);
// Let wallet handle adding additional inputs/fee as necessary.
req.shuffleOutputs = false;
req.missingSigsMode = Wallet.MissingSigsMode.USE_DUMMY_SIG;
wallet.completeTx(req); // TODO: Fix things so shuffling is usable.
feePaidForPayment = req.tx.getFee();
log.info("Calculated fee is {}", feePaidForPayment);

View File

@@ -2449,6 +2449,16 @@ public class WalletTest extends TestWithWallet {
completeTxPartiallySignedMarried(Wallet.MissingSigsMode.THROW, emptySig);
}
@Test (expected = TransactionSigner.MissingSignatureException.class)
public void completeTxPartiallySignedMarriedThrowsByDefault() throws Exception {
createMarriedWallet(false);
myAddress = wallet.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
sendMoneyToWallet(wallet, COIN, myAddress, AbstractBlockChain.NewBlockType.BEST_CHAIN);
Wallet.SendRequest req = Wallet.SendRequest.emptyWallet(new ECKey().toAddress(params));
wallet.completeTx(req);
}
public void completeTxPartiallySignedMarried(Wallet.MissingSigsMode missSigMode, byte[] expectedSig) throws Exception {
// create married wallet without signer
createMarriedWallet(false);