Use new `PubKey.GetAddress()`
MODIFY
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
@@ -67,7 +67,7 @@ namespace WalletWasabi.Tests.RegressionTests
var coinbaseTxId = bestBlock.Transactions[0].GetHash();
var offchainTxId = network.Consensus.ConsensusFactory.CreateTransaction().GetHash();
using var key = new Key();
- var mempoolTxId = await rpc.SendToAddressAsync(key.PubKey.GetSegwitAddress(network), Money.Coins(1));
+ var mempoolTxId = await rpc.SendToAddressAsync(key.PubKey.GetAddress(ScriptPubKeyType.Segwit, network), Money.Coins(1));
var folder = Helpers.Common.GetWorkDir();
await IoHelpers.TryDeleteDirectoryAsync(folder);
@@ -200,7 +200,7 @@ namespace WalletWasabi.Tests.RegressionTests
Assert.Equal($"{HttpStatusCode.BadRequest.ToReasonString()}\nProvided input is immature.", httpRequestException.Message);
var key = new Key();
- var witnessAddress = key.PubKey.GetSegwitAddress(network);
+ var witnessAddress = key.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
hash = await rpc.SendToAddressAsync(witnessAddress, Money.Coins(0.01m));
await rpc.GenerateAsync(1);
tx = await rpc.GetRawTransactionAsync(hash);
@@ -353,7 +353,7 @@ namespace WalletWasabi.Tests.RegressionTests
for (int j = 0; j < 8; j++)
{
key = new Key();
- witnessAddress = key.PubKey.GetSegwitAddress(network);
+ witnessAddress = key.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
hash = await rpc.SendToAddressAsync(witnessAddress, Money.Coins(0.01m));
await rpc.GenerateAsync(1);
tx = await rpc.GetRawTransactionAsync(hash);
@@ -419,7 +419,7 @@ namespace WalletWasabi.Tests.RegressionTests
var utxos = coordinator.UtxoReferee;
Assert.NotNull(await utxos.TryGetBannedAsync(bannedCoin, false));
spendingTx.Inputs.Add(new TxIn(bannedCoin));
- spendingTx.Outputs.Add(new TxOut(Money.Coins(1), new Key().PubKey.GetSegwitAddress(network)));
+ spendingTx.Outputs.Add(new TxOut(Money.Coins(1), new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network)));
await coordinator.ProcessConfirmedTransactionAsync(spendingTx);
Assert.NotNull(await utxos.TryGetBannedAsync(new OutPoint(spendingTx.GetHash(), 0), false));
@@ -440,7 +440,7 @@ namespace WalletWasabi.Tests.RegressionTests
// <-------------------------->
key = new Key();
- witnessAddress = key.PubKey.GetSegwitAddress(network);
+ witnessAddress = key.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
hash = await rpc.SendToAddressAsync(witnessAddress, Money.Coins(0.01m));
await rpc.GenerateAsync(1);
tx = await rpc.GetRawTransactionAsync(hash);
@@ -448,7 +448,7 @@ namespace WalletWasabi.Tests.RegressionTests
round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
requester = new Requester();
requesters = new[] { requester };
- BitcoinWitPubKeyAddress bitcoinWitPubKeyAddress = new Key().PubKey.GetSegwitAddress(network);
+ var bitcoinWitPubKeyAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
registeredAddresses = new[] { bitcoinWitPubKeyAddress };
Script script = bitcoinWitPubKeyAddress.ScriptPubKey;
nonce = round.NonceProvider.GetNextNonce();
@@ -535,8 +535,8 @@ namespace WalletWasabi.Tests.RegressionTests
var key1 = new Key();
var key2 = new Key();
- var outputAddress1 = key1.PubKey.GetSegwitAddress(network);
- var outputAddress2 = key2.PubKey.GetSegwitAddress(network);
+ var outputAddress1 = key1.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
+ var outputAddress2 = key2.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
var hash1 = await rpc.SendToAddressAsync(outputAddress1, Money.Coins(0.01m));
var hash2 = await rpc.SendToAddressAsync(outputAddress2, Money.Coins(0.01m));
await rpc.GenerateAsync(1);
@@ -721,18 +721,18 @@ namespace WalletWasabi.Tests.RegressionTests
// We have to 4 participant so, this data structure is for keeping track of
// important data for each of the participants in the coinjoin session.
var participants = new List<(AliceClient4 aliceClient,
- List<(Requester requester, BitcoinWitPubKeyAddress outputAddress, BlindedOutputWithNonceIndex blindedScript)> outouts,
+ List<(Requester requester, BitcoinAddress outputAddress, BlindedOutputWithNonceIndex blindedScript)> outouts,
List<(OutPoint input, byte[] proof, Coin coin, Key key)> inputs)>();
// INPUTS REGISTRATION PHASE --
for (var anosetIdx = 0; anosetIdx < anonymitySet; anosetIdx++)
{
// Create as many outputs as mixin levels (even when we do not have funds enough)
- var outputs = new List<(Requester requester, BitcoinWitPubKeyAddress outputAddress, BlindedOutputWithNonceIndex blindedScript)>();
+ var outputs = new List<(Requester requester, BitcoinAddress outputAddress, BlindedOutputWithNonceIndex blindedScript)>();
foreach (var level in round.MixingLevels.Levels)
{
var requester = new Requester();
- var outputsAddress = new Key().PubKey.GetSegwitAddress(network);
+ var outputsAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
var scriptPubKey = outputsAddress.ScriptPubKey;
// We blind the scriptPubKey with a new requester by mixin level
var nonce = round.NonceProvider.GetNextNonce();
@@ -750,7 +750,7 @@ namespace WalletWasabi.Tests.RegressionTests
for (var inputIdx = 0; inputIdx < 4; inputIdx++)
{
var key = new Key();
- var outputAddress = key.PubKey.GetSegwitAddress(network);
+ var outputAddress = key.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
var hash = await rpc.SendToAddressAsync(outputAddress, Money.Coins(0.1m));
await rpc.GenerateAsync(1);
var tx = await rpc.GetRawTransactionAsync(hash);
@@ -866,10 +866,10 @@ namespace WalletWasabi.Tests.RegressionTests
Uri baseUri = new(RegTestFixture.BackendEndPoint);
var spentCoins = new List<Coin>();
var fundingTxCount = 0;
- var inputRegistrationUsers = new List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData)>();
+ var inputRegistrationUsers = new List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData)>();
for (int i = 0; i < roundConfig.AnonymitySet; i++)
{
- var userInputData = new List<(Key key, BitcoinWitPubKeyAddress inputAddress, uint256 txHash, Transaction tx, OutPoint input)>();
+ var userInputData = new List<(Key key, BitcoinAddress inputAddress, uint256 txHash, Transaction tx, OutPoint input)>();
var activeOutputAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
var changeOutputAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
CoordinatorRound round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
@@ -890,7 +890,7 @@ namespace WalletWasabi.Tests.RegressionTests
{
receiveSatoshi = 100000000;
}
- BitcoinWitPubKeyAddress inputAddress = key.PubKey.GetSegwitAddress(network);
+ BitcoinWitPubKeyAddress inputAddress = key.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
uint256 txHash = await rpc.SendToAddressAsync(inputAddress, Money.Satoshis(receiveSatoshi));
fundingTxCount++;
Assert.NotNull(txHash);
@@ -942,7 +942,7 @@ namespace WalletWasabi.Tests.RegressionTests
}
long roundId = 0;
- var users = new List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient4 aliceClient, UnblindedSignature unblindedSignature)>();
+ var users = new List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient4 aliceClient, UnblindedSignature unblindedSignature)>();
for (int i = 0; i < inputRegistrationUsers.Count; i++)
{
var user = inputRegistrationUsers[i];

MODIFY
WalletWasabi.Tests/RegressionTests/DosTests.cs
WalletWasabi.Tests/RegressionTests/DosTests.cs
@@ -65,11 +65,11 @@ namespace WalletWasabi.Tests.RegressionTests
Uri baseUri = new(RegTestFixture.BackendEndPoint);
var fundingTxCount = 0;
- List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData)> inputRegistrationUsers = new();
- CoordinatorRound round = null;
+ List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData)> inputRegistrationUsers = new();
+ CoordinatorRound? round = null;
for (int i = 0; i < roundConfig.AnonymitySet; i++)
{
- List<(Key key, BitcoinWitPubKeyAddress inputAddress, uint256 txHash, Transaction tx, OutPoint input)> userInputData = new();
+ List<(Key key, BitcoinAddress inputAddress, uint256 txHash, Transaction tx, OutPoint input)> userInputData = new();
var activeOutputAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
var changeOutputAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
@@ -91,7 +91,7 @@ namespace WalletWasabi.Tests.RegressionTests
{
receiveSatoshi = 100000000;
}
- BitcoinWitPubKeyAddress inputAddress = key.PubKey.GetSegwitAddress(network);
+ var inputAddress = key.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
uint256 txHash = await rpc.SendToAddressAsync(inputAddress, Money.Satoshis(receiveSatoshi));
fundingTxCount++;
Assert.NotNull(txHash);
@@ -130,7 +130,7 @@ namespace WalletWasabi.Tests.RegressionTests
}
long roundId = 0;
- List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient4 aliceClient, UnblindedSignature unblindedSignature)> users = new();
+ List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient4 aliceClient, UnblindedSignature unblindedSignature)> users = new();
for (int i = 0; i < inputRegistrationUsers.Count; i++)
{
var user = inputRegistrationUsers[i];
@@ -202,7 +202,7 @@ namespace WalletWasabi.Tests.RegressionTests
}
roundId = 0;
- users = new List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient4 aliceClient, UnblindedSignature unblindedSignature)>();
+ users = new List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient4 aliceClient, UnblindedSignature unblindedSignature)>();
for (int i = 0; i < inputRegistrationUsers.Count; i++)
{
var user = inputRegistrationUsers[i];
@@ -269,15 +269,15 @@ namespace WalletWasabi.Tests.RegressionTests
Uri baseUri = new(RegTestFixture.BackendEndPoint);
- List<(BitcoinWitPubKeyAddress changeOutputAddress, BlindedOutputWithNonceIndex blindedData, InputProofModel[] inputsProofs)> registerRequests = new();
- AliceClient4 aliceClientBackup = null;
+ List<(BitcoinAddress changeOutputAddress, BlindedOutputWithNonceIndex blindedData, InputProofModel[] inputsProofs)> registerRequests = new();
+ AliceClient4? aliceClientBackup = null;
CoordinatorRound round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
for (int i = 0; i < roundConfig.AnonymitySet; i++)
{
- BitcoinWitPubKeyAddress activeOutputAddress = new Key().PubKey.GetSegwitAddress(network);
- BitcoinWitPubKeyAddress changeOutputAddress = new Key().PubKey.GetSegwitAddress(network);
+ var activeOutputAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
+ var changeOutputAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
Key inputKey = new();
- BitcoinWitPubKeyAddress inputAddress = inputKey.PubKey.GetSegwitAddress(network);
+ var inputAddress = inputKey.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
Requester requester = new();
var nonce = round.NonceProvider.GetNextNonce();

MODIFY
WalletWasabi.Tests/UnitTests/BitcoinCore/P2pBasedTests.cs
WalletWasabi.Tests/UnitTests/BitcoinCore/P2pBasedTests.cs
@@ -51,7 +51,7 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
node.VersionHandshake();
using Key k = new();
- BitcoinWitPubKeyAddress address = k.PubKey.GetSegwitAddress(network);
+ var address = k.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
// Number of transactions to send.
const int TransactionsCount = 3;
@@ -101,7 +101,7 @@ namespace WalletWasabi.Tests.UnitTests.BitcoinCore
var dir = Common.GetWorkDir();
using Key k = new();
- var addr = k.PubKey.GetSegwitAddress(network);
+ var addr = k.PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
var notifier = coreNode.MempoolService;
var txNum = 10;

MODIFY
WalletWasabi/Blockchain/Keys/HdPubKey.cs
WalletWasabi/Blockchain/Keys/HdPubKey.cs
@@ -136,9 +136,9 @@ namespace WalletWasabi.Blockchain.Keys
public BitcoinPubKeyAddress GetP2pkhAddress(Network network) => (BitcoinPubKeyAddress)PubKey.GetAddress(ScriptPubKeyType.Legacy, network);
- public BitcoinWitPubKeyAddress GetP2wpkhAddress(Network network) => PubKey.GetSegwitAddress(network);
+ public BitcoinWitPubKeyAddress GetP2wpkhAddress(Network network) => (BitcoinWitPubKeyAddress)PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
- public BitcoinScriptAddress GetP2shOverP2wpkhAddress(Network network) => P2wpkhScript.GetScriptAddress(network);
+ public BitcoinScriptAddress GetP2shOverP2wpkhAddress(Network network) => (BitcoinScriptAddress)PubKey.GetAddress(ScriptPubKeyType.SegwitP2SH, network);
public bool ContainsScript(Script scriptPubKey)
{

Use new `PubKey.GetAddress()`