diff --git a/src/main/java/com/sparrowwallet/drongo/crypto/ECKey.java b/src/main/java/com/sparrowwallet/drongo/crypto/ECKey.java index bc49ee5..996456c 100644 --- a/src/main/java/com/sparrowwallet/drongo/crypto/ECKey.java +++ b/src/main/java/com/sparrowwallet/drongo/crypto/ECKey.java @@ -576,9 +576,13 @@ public class ECKey { * @throws IllegalStateException if this ECKey does not have the private part. */ public String signMessage(String message, ScriptType scriptType) { + return signMessage(message, scriptType, this::signEcdsa); + } + + public String signMessage(String message, ScriptType scriptType, ECDSAHashSigner ecdsaHashSigner) { byte[] data = formatMessageForSigning(message); Sha256Hash hash = Sha256Hash.twiceOf(data); - ECDSASignature sig = signEcdsa(hash); + ECDSASignature sig = ecdsaHashSigner.sign(hash); byte recId = findRecoveryId(hash, sig); int headerByte = recId + getSigningTypeConstant(scriptType); byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32 bytes for S @@ -868,4 +872,8 @@ public class ECKey { throw new RuntimeException(e); // Cannot happen. } } + + public interface ECDSAHashSigner { + ECDSASignature sign(Sha256Hash hash); + } } diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java b/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java index f5fda81..4abf6c5 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/WalletModel.java @@ -66,6 +66,10 @@ public enum WalletModel { return (this == TREZOR_1 || this == KEEPKEY); } + public boolean isCard() { + return (this == TAPSIGNER || this == SATSCARD); + } + public static WalletModel fromType(String type) { for(WalletModel model : values()) { if(model.getType().equalsIgnoreCase(type)) {