Code format fixes
MODIFY
WalletWasabi.Tests/UnitTests/Transactions/PayjoinTests.cs
WalletWasabi.Tests/UnitTests/Transactions/PayjoinTests.cs
@@ -137,8 +137,8 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
var diff = Money.Coins(0.0007m);
var paymentOutput = globalTx.Outputs.Single(x => x.ScriptPubKey == destination);
var changeOutput = globalTx.Outputs.Single(x => x.ScriptPubKey != destination);
- changeOutput.Value = changeOutput.Value - diff;
- paymentOutput.Value = paymentOutput.Value + diff;
+ changeOutput.Value -= diff;
+ paymentOutput.Value += diff;
return PSBT.FromTransaction(globalTx, Network.Main);
})
@@ -268,7 +268,7 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
OnSendAsync = PayjoinServer(psbt =>
{
var globalTx = psbt.GetGlobalTransaction();
- globalTx.Version = globalTx.Version + 1;
+ globalTx.Version += 1;
return PSBT.FromTransaction(globalTx, Network.Main);
})
};
@@ -308,7 +308,7 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
{
var globalTx = psbt.GetGlobalTransaction();
var changeOutput = globalTx.Outputs.Single(x => x.ScriptPubKey != destination);
- changeOutput.Value = changeOutput.Value - Money.Coins(0.0007m);;
+ changeOutput.Value -= Money.Coins(0.0007m); ;
return PSBT.FromTransaction(globalTx, Network.Main);
})
};

MODIFY
WalletWasabi/Extensions/NBitcoinExtensions.cs
WalletWasabi/Extensions/NBitcoinExtensions.cs
@@ -378,24 +378,29 @@ namespace NBitcoin
public static ScriptPubKeyType? GetInputsScriptPubKeyType(this PSBT psbt)
{
if (!psbt.IsAllFinalized() || psbt.Inputs.Any(i => i.WitnessUtxo is null))
+ {
throw new InvalidOperationException("The psbt should be finalized with witness information");
+ }
+
var coinsPerTypes = psbt.Inputs.Select(i =>
{
return ((PSBTCoin)i, i.GetInputScriptPubKeyType());
}).GroupBy(o => o.Item2, o => o.Item1).ToArray();
- if (coinsPerTypes.Length != 1)
- return default;
- return coinsPerTypes[0].Key;
+
+ return coinsPerTypes.Length != 1 ? (default) : coinsPerTypes[0].Key;
}
public static ScriptPubKeyType? GetInputScriptPubKeyType(this PSBTInput i)
{
if (i.WitnessUtxo.ScriptPubKey.IsScriptType(ScriptType.P2WPKH))
+ {
return ScriptPubKeyType.Segwit;
- if (i.WitnessUtxo.ScriptPubKey.IsScriptType(ScriptType.P2SH) &&
- i.FinalScriptWitness.ToScript().IsScriptType(ScriptType.P2WPKH))
- return ScriptPubKeyType.SegwitP2SH;
- return null as ScriptPubKeyType?;
+ }
+
+ return i.WitnessUtxo.ScriptPubKey.IsScriptType(ScriptType.P2SH) &&
+ i.FinalScriptWitness.ToScript().IsScriptType(ScriptType.P2WPKH)
+ ? (ScriptPubKeyType?)ScriptPubKeyType.SegwitP2SH
+ : null as ScriptPubKeyType?;
}
}
}

Code format fixes