Script: Remove deprecated decodeFromBitcoin() variant.

This commit is contained in:
Andreas Schildbach 2018-11-02 12:51:15 +01:00
parent 9485db40e8
commit 64e74d3a56
4 changed files with 4 additions and 18 deletions

View file

@ -156,20 +156,6 @@ public class TransactionSignature extends ECKey.ECDSASignature {
return new TransactionSignature(super.toCanonicalised(), sigHashMode(), anyoneCanPay()); return new TransactionSignature(super.toCanonicalised(), sigHashMode(), anyoneCanPay());
} }
/**
* Returns a decoded signature.
*
* @param requireCanonicalEncoding if the encoding of the signature must
* be canonical.
* @throws RuntimeException if the signature is invalid or unparseable in some way.
* @deprecated use {@link #decodeFromBitcoin(byte[], boolean, boolean)} instead}.
*/
@Deprecated
public static TransactionSignature decodeFromBitcoin(byte[] bytes,
boolean requireCanonicalEncoding) throws VerificationException {
return decodeFromBitcoin(bytes, requireCanonicalEncoding, false);
}
/** /**
* Returns a decoded signature. * Returns a decoded signature.
* *

View file

@ -240,7 +240,7 @@ public abstract class PaymentChannelServerState {
stateMachine.checkState(State.READY); stateMachine.checkState(State.READY);
checkNotNull(refundSize); checkNotNull(refundSize);
checkNotNull(signatureBytes); checkNotNull(signatureBytes);
TransactionSignature signature = TransactionSignature.decodeFromBitcoin(signatureBytes, true); TransactionSignature signature = TransactionSignature.decodeFromBitcoin(signatureBytes, true, false);
// We allow snapping to zero for the payment amount because it's treated specially later, but not less than // We allow snapping to zero for the payment amount because it's treated specially later, but not less than
// the dust level because that would prevent the transaction from being relayed/mined. // the dust level because that would prevent the transaction from being relayed/mined.
final boolean fullyUsedUp = refundSize.equals(Coin.ZERO); final boolean fullyUsedUp = refundSize.equals(Coin.ZERO);

View file

@ -230,7 +230,7 @@ public class PaymentChannelV1ClientState extends PaymentChannelClientState {
throws VerificationException { throws VerificationException {
checkNotNull(theirSignature); checkNotNull(theirSignature);
stateMachine.checkState(State.WAITING_FOR_SIGNED_REFUND); stateMachine.checkState(State.WAITING_FOR_SIGNED_REFUND);
TransactionSignature theirSig = TransactionSignature.decodeFromBitcoin(theirSignature, true); TransactionSignature theirSig = TransactionSignature.decodeFromBitcoin(theirSignature, true, false);
if (theirSig.sigHashMode() != Transaction.SigHash.NONE || !theirSig.anyoneCanPay()) if (theirSig.sigHashMode() != Transaction.SigHash.NONE || !theirSig.anyoneCanPay())
throw new VerificationException("Refund signature was not SIGHASH_NONE|SIGHASH_ANYONECANPAY"); throw new VerificationException("Refund signature was not SIGHASH_NONE|SIGHASH_ANYONECANPAY");
// Sign the refund transaction ourselves. // Sign the refund transaction ourselves.

View file

@ -470,7 +470,7 @@ public class Script {
private int findSigInRedeem(byte[] signatureBytes, Sha256Hash hash) { private int findSigInRedeem(byte[] signatureBytes, Sha256Hash hash) {
checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig checkArgument(chunks.get(0).isOpCode()); // P2SH scriptSig
int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode); int numKeys = Script.decodeFromOpN(chunks.get(chunks.size() - 2).opcode);
TransactionSignature signature = TransactionSignature.decodeFromBitcoin(signatureBytes, true); TransactionSignature signature = TransactionSignature.decodeFromBitcoin(signatureBytes, true, false);
for (int i = 0 ; i < numKeys ; i++) { for (int i = 0 ; i < numKeys ; i++) {
if (ECKey.fromPublicOnly(chunks.get(i + 1).data).verify(hash, signature)) { if (ECKey.fromPublicOnly(chunks.get(i + 1).data).verify(hash, signature)) {
return i; return i;
@ -1484,7 +1484,7 @@ public class Script {
// We could reasonably move this out of the loop, but because signature verification is significantly // We could reasonably move this out of the loop, but because signature verification is significantly
// more expensive than hashing, its not a big deal. // more expensive than hashing, its not a big deal.
try { try {
TransactionSignature sig = TransactionSignature.decodeFromBitcoin(sigs.getFirst(), requireCanonical); TransactionSignature sig = TransactionSignature.decodeFromBitcoin(sigs.getFirst(), requireCanonical, false);
Sha256Hash hash = txContainingThis.hashForSignature(index, connectedScript, (byte) sig.sighashFlags); Sha256Hash hash = txContainingThis.hashForSignature(index, connectedScript, (byte) sig.sighashFlags);
if (ECKey.verify(hash.getBytes(), sig, pubKey)) if (ECKey.verify(hash.getBytes(), sig, pubKey))
sigs.pollFirst(); sigs.pollFirst();