diff --git a/core/src/main/java/com/google/bitcoin/core/Wallet.java b/core/src/main/java/com/google/bitcoin/core/Wallet.java index 1e23a91d..622a290c 100644 --- a/core/src/main/java/com/google/bitcoin/core/Wallet.java +++ b/core/src/main/java/com/google/bitcoin/core/Wallet.java @@ -3318,7 +3318,7 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha // Now sign the inputs, thus proving that we are entitled to redeem the connected outputs. if (req.signInputs) { - signTransaction(req.tx, Transaction.SigHash.ALL, req.aesKey); + signTransaction(req.tx, req.aesKey); } // Check size. @@ -3349,21 +3349,15 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha /** *

Signs given transaction. Actual signing is done by pluggable {@link #signers} and it's not guaranteed that - * transaction will be complete in the end.

- *

Only {@link com.google.bitcoin.core.Transaction.SigHash#ALL} signing mode is currently supported

- *

Optional aesKey should be provided if this wallet is encrypted

+ * transaction will be complete in the end. Optional aesKey should be provided if this wallet is encrypted

*/ - public void signTransaction(Transaction tx, Transaction.SigHash hashType, @Nullable KeyParameter aesKey) { + public void signTransaction(Transaction tx, @Nullable KeyParameter aesKey) { lock.lock(); try { List inputs = tx.getInputs(); List outputs = tx.getOutputs(); checkState(inputs.size() > 0); checkState(outputs.size() > 0); - - // I don't currently have an easy way to test other modes work, as the official client does not use them. - checkArgument(hashType == Transaction.SigHash.ALL, "Only SIGHASH_ALL is currently supported"); - KeyBag maybeDecryptingKeyBag = aesKey != null ? new DecryptingKeyBag(this, aesKey) : this; for (TransactionSigner signer : signers) { if (!signer.signInputs(tx, maybeDecryptingKeyBag)) @@ -4270,7 +4264,7 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha } rekeyTx.getConfidence().setSource(TransactionConfidence.Source.SELF); rekeyTx.setPurpose(Transaction.Purpose.KEY_ROTATION); - signTransaction(rekeyTx, Transaction.SigHash.ALL, aesKey); + signTransaction(rekeyTx, aesKey); // KeyTimeCoinSelector should never select enough inputs to push us oversize. checkState(rekeyTx.bitcoinSerialize().length < Transaction.MAX_STANDARD_TX_SIZE); return rekeyTx; diff --git a/core/src/test/java/com/google/bitcoin/core/WalletTest.java b/core/src/test/java/com/google/bitcoin/core/WalletTest.java index 0efa1185..b46e1106 100644 --- a/core/src/test/java/com/google/bitcoin/core/WalletTest.java +++ b/core/src/test/java/com/google/bitcoin/core/WalletTest.java @@ -1356,7 +1356,7 @@ public class WalletTest extends TestWithWallet { Transaction t3 = new Transaction(params); t3.addOutput(v3, k3.toAddress(params)); t3.addInput(o2); - wallet.signTransaction(t3, Transaction.SigHash.ALL, null); + wallet.signTransaction(t3, null); // Commit t3, so the coins from the pending t2 are spent wallet.commitTx(t3); @@ -1897,7 +1897,7 @@ public class WalletTest extends TestWithWallet { Transaction spendTx5 = new Transaction(params); spendTx5.addOutput(CENT, notMyAddr); spendTx5.addInput(tx5.getOutput(0)); - wallet.signTransaction(spendTx5, Transaction.SigHash.ALL, null); + wallet.signTransaction(spendTx5, null); wallet.receiveFromBlock(spendTx5, block, AbstractBlockChain.NewBlockType.BEST_CHAIN, 4); assertEquals(COIN, wallet.getBalance()); @@ -2148,7 +2148,7 @@ public class WalletTest extends TestWithWallet { SendRequest request4 = SendRequest.to(notMyAddr, CENT); request4.tx.addInput(tx3.getOutput(0)); // Now if we manually sign it, completeTx will not replace our signature - wallet.signTransaction(request4.tx, Transaction.SigHash.ALL, null); + wallet.signTransaction(request4.tx, null); byte[] scriptSig = request4.tx.getInput(0).getScriptBytes(); wallet.completeTx(request4); assertEquals(1, request4.tx.getInputs().size()); diff --git a/tools/src/main/java/com/google/bitcoin/tools/WalletTool.java b/tools/src/main/java/com/google/bitcoin/tools/WalletTool.java index 1dd7998c..bd6e11e1 100644 --- a/tools/src/main/java/com/google/bitcoin/tools/WalletTool.java +++ b/tools/src/main/java/com/google/bitcoin/tools/WalletTool.java @@ -550,7 +550,7 @@ public class WalletTool { // For lock times to take effect, at least one output must have a non-final sequence number. t.getInputs().get(0).setSequenceNumber(0); // And because we modified the transaction after it was completed, we must re-sign the inputs. - wallet.signTransaction(t, Transaction.SigHash.ALL, req.aesKey); + wallet.signTransaction(t, req.aesKey); } } catch (ParseException e) { System.err.println("Could not understand --locktime of " + lockTimeStr);