fixup! Implement GetScriptType
MODIFY
WalletWasabi/Crypto/Bip322Signature.cs
WalletWasabi/Crypto/Bip322Signature.cs
@@ -41,7 +41,7 @@ public record Bip322Signature : IBitcoinSerializable
NBitcoinExtensions.FromBytes<Bip322Signature>(bip322SignatureBytes);
public bool Verify(uint256 hash, Script scriptPubKey) =>
- scriptPubKey.GetScriptType() switch
+ scriptPubKey.TryGetScriptType() switch
{
ScriptType.P2WPKH => VerifyP2wpkh(hash, scriptPubKey),
ScriptType.Taproot => VerifyP2tr(hash, scriptPubKey),

MODIFY
WalletWasabi/Crypto/OwnershipProof.cs
WalletWasabi/Crypto/OwnershipProof.cs
@@ -47,7 +47,7 @@ public record OwnershipProof : IBitcoinSerializable
Bip322Signature.Generate(key, proofBody.SignatureHash(key.PubKey.GetScriptPubKey(scriptPubKeyType), commitmentData), scriptPubKeyType));
public bool VerifyOwnership(Script scriptPubKey, byte[] commitmentData, bool requireUserConfirmation) =>
- scriptPubKey.GetScriptType() switch
+ scriptPubKey.TryGetScriptType() switch
{
ScriptType.P2WPKH or ScriptType.Taproot => VerifyOwnershipProof(scriptPubKey, commitmentData, requireUserConfirmation),
_ => throw new NotImplementedException("Only P2WPKH and P2TR scripts are supported."),

MODIFY
WalletWasabi/Extensions/NBitcoinExtensions.cs
WalletWasabi/Extensions/NBitcoinExtensions.cs
@@ -353,19 +353,6 @@ public static class NBitcoinExtensions
}
}
- public static ScriptType? GetScriptType(this Script script)
- {
- foreach (ScriptType scriptType in new ScriptType[] { ScriptType.P2WPKH, ScriptType.Taproot })
- {
- if (script.IsScriptType(scriptType))
- {
- return scriptType;
- }
- }
-
- return null;
- }
-
public static ScriptPubKeyType? GetInputScriptPubKeyType(this PSBTInput i)
{
if (i.WitnessUtxo is null)
@@ -475,7 +462,7 @@ public static class NBitcoinExtensions
new TxOut(Money.Zero, scriptPubKey).GetSerializedSize();
public static int EstimateInputVsize(this Script scriptPubKey) =>
- scriptPubKey.GetScriptType() switch
+ scriptPubKey.TryGetScriptType() switch
{
ScriptType.P2WPKH => Constants.P2wpkhInputVirtualSize,
ScriptType.Taproot => Constants.P2trInputVirtualSize,

fixup! Implement GetScriptType