Add configuration option for allowed input and output script types
MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/RoundParameters.cs
WalletWasabi/WabiSabi/Backend/Rounds/RoundParameters.cs
+using System;
using System.Collections.Immutable;
using NBitcoin;
using NBitcoin.Policy;
+using WalletWasabi.Helpers;
using WalletWasabi.WabiSabi.Models;
using WalletWasabi.WabiSabi.Models.MultipartyTransaction;
@@ -19,6 +21,8 @@ public record RoundParameters
int maxInputCountByRound,
MoneyRange allowedInputAmounts,
MoneyRange allowedOutputAmounts,
+ ImmutableSortedSet<ScriptType> allowedInputScriptTypes,
+ ImmutableSortedSet<ScriptType> allowedOutputScriptTypes,
TimeSpan standardInputRegistrationTimeout,
TimeSpan connectionConfirmationTimeout,
TimeSpan outputRegistrationTimeout,
@@ -34,6 +38,8 @@ public record RoundParameters
MaxInputCountByRound = maxInputCountByRound;
AllowedInputAmounts = allowedInputAmounts;
AllowedOutputAmounts = allowedOutputAmounts;
+ AllowedInputScriptTypes = allowedInputScriptTypes;
+ AllowedOutputScriptTypes = allowedOutputScriptTypes;
StandardInputRegistrationTimeout = standardInputRegistrationTimeout;
ConnectionConfirmationTimeout = connectionConfirmationTimeout;
OutputRegistrationTimeout = outputRegistrationTimeout;
@@ -54,15 +60,14 @@ public record RoundParameters
public int MaxInputCountByRound { get; init; }
public MoneyRange AllowedInputAmounts { get; init; }
public MoneyRange AllowedOutputAmounts { get; init; }
+ public ImmutableSortedSet<ScriptType> AllowedInputScriptTypes { get; init; }
+ public ImmutableSortedSet<ScriptType> AllowedOutputScriptTypes { get; init; }
public TimeSpan StandardInputRegistrationTimeout { get; init; }
public TimeSpan ConnectionConfirmationTimeout { get; init; }
public TimeSpan OutputRegistrationTimeout { get; init; }
public TimeSpan TransactionSigningTimeout { get; init; }
public TimeSpan BlameInputRegistrationTimeout { get; init; }
- public ImmutableSortedSet<ScriptType> AllowedInputScriptTypes { get; init; } = OnlyP2WPKH;
- public ImmutableSortedSet<ScriptType> AllowedOutputScriptTypes { get; init; } = OnlyP2WPKH;
-
public Money MinAmountCredentialValue => AllowedInputAmounts.Min;
public Money MaxAmountCredentialValue => AllowedInputAmounts.Max;
@@ -98,6 +103,8 @@ public record RoundParameters
wabiSabiConfig.MaxInputCountByRound,
new MoneyRange(wabiSabiConfig.MinRegistrableAmount, wabiSabiConfig.MaxRegistrableAmount),
new MoneyRange(wabiSabiConfig.MinRegistrableAmount, wabiSabiConfig.MaxRegistrableAmount),
+ wabiSabiConfig.AllowedInputScriptTypes,
+ wabiSabiConfig.AllowedOutputScriptTypes,
wabiSabiConfig.StandardInputRegistrationTimeout,
wabiSabiConfig.ConnectionConfirmationTimeout,
wabiSabiConfig.OutputRegistrationTimeout,

MODIFY
WalletWasabi/WabiSabi/Backend/WabiSabiConfig.cs
WalletWasabi/WabiSabi/Backend/WabiSabiConfig.cs
using NBitcoin;
using Newtonsoft.Json;
+using System.Collections.Generic;
+using System.Collections.Immutable;
using System.ComponentModel;
using WalletWasabi.Bases;
using WalletWasabi.Helpers;
@@ -124,6 +126,18 @@ public class WabiSabiConfig : ConfigBase
[JsonProperty(PropertyName = "CoordinatorIdentifier", DefaultValueHandling = DefaultValueHandling.Populate)]
public string CoordinatorIdentifier { get; set; } = "CoinJoinCoordinatorIdentifier";
+ [DefaultValue(true)]
+ [JsonProperty(PropertyName = "AllowP2wpkhInputs", DefaultValueHandling = DefaultValueHandling.Populate)]
+ public bool AllowP2wpkhInputs { get; set; } = true;
+
+ [DefaultValue(true)]
+ [JsonProperty(PropertyName = "AllowP2wpkhOutputs", DefaultValueHandling = DefaultValueHandling.Populate)]
+ public bool AllowP2wpkhOutputs { get; set; } = true;
+
+ public ImmutableSortedSet<ScriptType> AllowedInputScriptTypes => GetScriptTypes(AllowP2wpkhInputs);
+
+ public ImmutableSortedSet<ScriptType> AllowedOutputScriptTypes => GetScriptTypes(AllowP2wpkhOutputs);
+
public Script GetNextCleanCoordinatorScript() => DeriveCoordinatorScript(CoordinatorExtPubKeyCurrentDepth);
public Script DeriveCoordinatorScript(int index) => CoordinatorExtPubKey.Derive(0, false).Derive(index, false).PubKey.GetScriptPubKey(ScriptPubKeyType.Segwit);
@@ -136,4 +150,18 @@ public class WabiSabiConfig : ConfigBase
ToFile();
}
}
+
+ private static ImmutableSortedSet<ScriptType> GetScriptTypes(bool p2wpkh)
+ {
+ var scriptTypes = new List<ScriptType>();
+ if (p2wpkh)
+ {
+ scriptTypes.Add(ScriptType.P2WPKH);
+ }
+
+ // When adding new script types, please see
+ // https://github.com/zkSNACKs/WalletWasabi/issues/5440
+
+ return scriptTypes.ToImmutableSortedSet();
+ }
}

Add configuration option for allowed input and output script types