Wallet: in signTransaction() don't care about the witness being empty

It does not matter for the data being signed.

This removes `Script.createEmptyWitness()` as it's unnecessary as well.
This commit is contained in:
Andreas Schildbach 2023-04-10 10:39:01 +02:00
parent ce07733bbf
commit d4f8058164
2 changed files with 0 additions and 14 deletions

View file

@ -566,19 +566,6 @@ public class Script {
}
}
public TransactionWitness createEmptyWitness(ECKey key) {
if (ScriptPattern.isP2WPKH(this)) {
checkArgument(key != null, () ->
"key required to create P2WPKH witness");
return TransactionWitness.EMPTY;
} else if (ScriptPattern.isP2PK(this) || ScriptPattern.isP2PKH(this)
|| ScriptPattern.isP2SH(this)) {
return null; // no witness
} else {
throw new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "Do not understand script type: " + this);
}
}
/**
* Returns a copy of the given scriptSig with the signature inserted in the given position.
*/

View file

@ -4579,7 +4579,6 @@ public class Wallet extends BaseTaggableObject
Objects.requireNonNull(redeemData, () ->
"Transaction exists in wallet that we cannot redeem: " + txIn.getOutpoint().hash());
txIn.setScriptSig(scriptPubKey.createEmptyInputScript(redeemData.keys.get(0), redeemData.redeemScript));
txIn.setWitness(scriptPubKey.createEmptyWitness(redeemData.keys.get(0)));
}
TransactionSigner.ProposedTransaction proposal = new TransactionSigner.ProposedTransaction(tx);