mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Remove useless code (#6817)
* Remove unused code * Obsolete SigningKey concept
This commit is contained in:
@@ -1166,11 +1166,11 @@ bc1qfzu57kgu5jthl934f9xrdzzx8mmemx7gn07tf0grnvz504j6kzusu2v0ku
|
|||||||
""";
|
""";
|
||||||
Assert.True(parsers.TryParseWalletFile(electrumText, mainnet, out electrum, out _));
|
Assert.True(parsers.TryParseWalletFile(electrumText, mainnet, out electrum, out _));
|
||||||
Assert.Equal("ElectrumFile", electrum.Source);
|
Assert.Equal("ElectrumFile", electrum.Source);
|
||||||
Assert.Equal("0'", electrum.GetSigningAccountKeySettings().AccountKeyPath.ToString());
|
Assert.Equal("0'", electrum.GetFirstAccountKeySettings().AccountKeyPath.ToString());
|
||||||
Assert.True(electrum.AccountDerivation is DirectDerivationStrategy { Segwit: true });
|
Assert.True(electrum.AccountDerivation is DirectDerivationStrategy { Segwit: true });
|
||||||
Assert.Equal("fbb5b37d", electrum.GetSigningAccountKeySettings().RootFingerprint.ToString());
|
Assert.Equal("fbb5b37d", electrum.GetFirstAccountKeySettings().RootFingerprint.ToString());
|
||||||
Assert.Equal("zpub6oQLDcJLztdMD29C8D8eyZKdKVfX9txB4BxZsMif9avJZBdVWPg1wmK3Uh3VxU7KXon1wm1xzvjyqmKWguYMqyjKP5f5Cho9f7uLfmRt2Br", electrum.AccountOriginal);
|
Assert.Equal("zpub6oQLDcJLztdMD29C8D8eyZKdKVfX9txB4BxZsMif9avJZBdVWPg1wmK3Uh3VxU7KXon1wm1xzvjyqmKWguYMqyjKP5f5Cho9f7uLfmRt2Br", electrum.AccountOriginal);
|
||||||
Assert.Equal(((DirectDerivationStrategy)electrum.AccountDerivation).GetExtPubKeys().First().ParentFingerprint.ToString(), electrum.GetSigningAccountKeySettings().RootFingerprint.ToString());
|
Assert.Equal(((DirectDerivationStrategy)electrum.AccountDerivation).GetExtPubKeys().First().ParentFingerprint.ToString(), electrum.GetFirstAccountKeySettings().RootFingerprint.ToString());
|
||||||
|
|
||||||
// Electrum with strange garbage at the end caused by the lightning support
|
// Electrum with strange garbage at the end caused by the lightning support
|
||||||
electrumText =
|
electrumText =
|
||||||
|
|||||||
@@ -471,7 +471,7 @@ namespace BTCPayServer.Tests
|
|||||||
}
|
}
|
||||||
|
|
||||||
var derivationSchemeSettings = alice.GetController<UIWalletsController>().GetDerivationSchemeSettings(new WalletId(alice.StoreId, "BTC"));
|
var derivationSchemeSettings = alice.GetController<UIWalletsController>().GetDerivationSchemeSettings(new WalletId(alice.StoreId, "BTC"));
|
||||||
var signingAccount = derivationSchemeSettings.GetSigningAccountKeySettings();
|
var signingAccount = derivationSchemeSettings.GetFirstAccountKeySettings();
|
||||||
psbt.SignAll(derivationSchemeSettings.AccountDerivation, alice.GenerateWalletResponseV.AccountHDKey, signingAccount.GetRootedKeyPath());
|
psbt.SignAll(derivationSchemeSettings.AccountDerivation, alice.GenerateWalletResponseV.AccountHDKey, signingAccount.GetRootedKeyPath());
|
||||||
using var fakeServer = new FakeServer();
|
using var fakeServer = new FakeServer();
|
||||||
await fakeServer.Start();
|
await fakeServer.Start();
|
||||||
@@ -940,7 +940,7 @@ retry:
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var signingKeySettings = derivationSchemeSettings.GetSigningAccountKeySettings();
|
var signingKeySettings = derivationSchemeSettings.GetFirstAccountKeySettings();
|
||||||
signingKeySettings.RootFingerprint =
|
signingKeySettings.RootFingerprint =
|
||||||
senderUser.GenerateWalletResponseV.MasterHDKey.GetPublicKey().GetHDFingerPrint();
|
senderUser.GenerateWalletResponseV.MasterHDKey.GetPublicKey().GetHDFingerPrint();
|
||||||
|
|
||||||
@@ -981,8 +981,8 @@ retry:
|
|||||||
.BuildTransaction(true);
|
.BuildTransaction(true);
|
||||||
|
|
||||||
|
|
||||||
//Attempt 2: Create two transactions using different inputs and send them to the same invoice.
|
//Attempt 2: Create two transactions using different inputs and send them to the same invoice.
|
||||||
//Result: Second Tx should be rejected.
|
//Result: Second Tx should be rejected.
|
||||||
var Invoice1Coin1ResponseTx = await senderUser.SubmitPayjoin(invoice, Invoice1Coin1, btcPayNetwork);
|
var Invoice1Coin1ResponseTx = await senderUser.SubmitPayjoin(invoice, Invoice1Coin1, btcPayNetwork);
|
||||||
|
|
||||||
await senderUser.SubmitPayjoin(invoice, Invoice1Coin1, btcPayNetwork, "already-paid");
|
await senderUser.SubmitPayjoin(invoice, Invoice1Coin1, btcPayNetwork, "already-paid");
|
||||||
|
|||||||
@@ -2828,8 +2828,7 @@ namespace BTCPayServer.Tests
|
|||||||
var v = store.GetPaymentMethodConfig<DerivationSchemeSettings>(pmi, handlers);
|
var v = store.GetPaymentMethodConfig<DerivationSchemeSettings>(pmi, handlers);
|
||||||
Assert.Equal(derivation, v.AccountDerivation.ToString());
|
Assert.Equal(derivation, v.AccountDerivation.ToString());
|
||||||
Assert.Equal(derivation, v.AccountOriginal);
|
Assert.Equal(derivation, v.AccountOriginal);
|
||||||
Assert.Equal(xpub, v.SigningKey.ToString());
|
Assert.Equal(xpub, v.GetFirstAccountKeySettings().AccountKey.ToString());
|
||||||
Assert.Equal(xpub, v.GetSigningAccountKeySettings().AccountKey.ToString());
|
|
||||||
|
|
||||||
await acc.RegisterLightningNodeAsync("BTC", LightningConnectionType.CLightning, true);
|
await acc.RegisterLightningNodeAsync("BTC", LightningConnectionType.CLightning, true);
|
||||||
store = await tester.PayTester.StoreRepository.FindStore(acc.StoreId);
|
store = await tester.PayTester.StoreRepository.FindStore(acc.StoreId);
|
||||||
|
|||||||
@@ -580,8 +580,8 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
|
|
||||||
var signingKey = ExtKey.Parse(signingKeyStr, network.NBitcoinNetwork);
|
var signingKey = ExtKey.Parse(signingKeyStr, network.NBitcoinNetwork);
|
||||||
|
|
||||||
var signingKeySettings = derivationScheme.GetSigningAccountKeySettings(signingKey);
|
var signingKeySettings = derivationScheme.GetAccountKeySettingsFromRoot(signingKey);
|
||||||
RootedKeyPath? rootedKeyPath = signingKeySettings?.GetRootedKeyPath();
|
var rootedKeyPath = signingKeySettings?.GetRootedKeyPath();
|
||||||
if (rootedKeyPath is null || signingKeySettings is null)
|
if (rootedKeyPath is null || signingKeySettings is null)
|
||||||
{
|
{
|
||||||
return this.CreateAPIError(503, "not-available",
|
return this.CreateAPIError(503, "not-available",
|
||||||
|
|||||||
@@ -407,13 +407,12 @@ public partial class UIStoresController
|
|||||||
Network = network,
|
Network = network,
|
||||||
IsHotWallet = derivation.IsHotWallet,
|
IsHotWallet = derivation.IsHotWallet,
|
||||||
Source = derivation.Source,
|
Source = derivation.Source,
|
||||||
RootFingerprint = derivation.GetSigningAccountKeySettingsOrDefault()?.RootFingerprint.ToString(),
|
RootFingerprint = derivation.GetFirstAccountKeySettings().RootFingerprint.ToString(),
|
||||||
DerivationScheme = derivation.AccountDerivation?.ToString(),
|
DerivationScheme = derivation.AccountDerivation?.ToString(),
|
||||||
DerivationSchemeInput = derivation.AccountOriginal,
|
DerivationSchemeInput = derivation.AccountOriginal,
|
||||||
KeyPath = derivation.GetSigningAccountKeySettingsOrDefault()?.AccountKeyPath?.ToString(),
|
KeyPath = derivation.GetFirstAccountKeySettings().AccountKeyPath?.ToString(),
|
||||||
UriScheme = network.NBitcoinNetwork.UriScheme,
|
UriScheme = network.NBitcoinNetwork.UriScheme,
|
||||||
Label = derivation.Label,
|
Label = derivation.Label,
|
||||||
SelectedSigningKey = derivation.SigningKey?.ToString(),
|
|
||||||
NBXSeedAvailable = derivation.IsHotWallet &&
|
NBXSeedAvailable = derivation.IsHotWallet &&
|
||||||
perm.CanCreateHotWallet &&
|
perm.CanCreateHotWallet &&
|
||||||
!string.IsNullOrEmpty(await client.GetMetadataAsync<string>(derivation.AccountDerivation,
|
!string.IsNullOrEmpty(await client.GetMetadataAsync<string>(derivation.AccountDerivation,
|
||||||
@@ -480,15 +479,6 @@ public partial class UIStoresController
|
|||||||
derivation.DefaultIncludeNonWitnessUtxo = vm.DefaultIncludeNonWitnessUtxo;
|
derivation.DefaultIncludeNonWitnessUtxo = vm.DefaultIncludeNonWitnessUtxo;
|
||||||
}
|
}
|
||||||
|
|
||||||
var signingKey = string.IsNullOrEmpty(vm.SelectedSigningKey)
|
|
||||||
? null
|
|
||||||
: new BitcoinExtPubKey(vm.SelectedSigningKey, network.NBitcoinNetwork);
|
|
||||||
if (derivation.SigningKey != signingKey && signingKey != null)
|
|
||||||
{
|
|
||||||
needUpdate = true;
|
|
||||||
derivation.SigningKey = signingKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < derivation.AccountKeySettings.Length; i++)
|
for (int i = 0; i < derivation.AccountKeySettings.Length; i++)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ namespace BTCPayServer.Controllers
|
|||||||
|
|
||||||
if (signingKey == null || signingKeyPath == null)
|
if (signingKey == null || signingKeyPath == null)
|
||||||
{
|
{
|
||||||
var signingKeySettings = derivationSchemeSettings.GetSigningAccountKeySettings();
|
var signingKeySettings = derivationSchemeSettings.GetFirstAccountKeySettings();
|
||||||
if (signingKey == null)
|
if (signingKey == null)
|
||||||
{
|
{
|
||||||
signingKey = signingKeySettings.AccountKey;
|
signingKey = signingKeySettings.AccountKey;
|
||||||
|
|||||||
@@ -997,7 +997,7 @@ namespace BTCPayServer.Controllers
|
|||||||
Labels = _labelService.CreateTransactionTagModels(info, Request),
|
Labels = _labelService.CreateTransactionTagModels(info, Request),
|
||||||
Link = _transactionLinkProviders.GetTransactionLink(pmi, coin.OutPoint.ToString()),
|
Link = _transactionLinkProviders.GetTransactionLink(pmi, coin.OutPoint.ToString()),
|
||||||
Confirmations = coin.Confirmations,
|
Confirmations = coin.Confirmations,
|
||||||
Timestamp = coin.Timestamp
|
Timestamp = coin.Timestamp
|
||||||
};
|
};
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
@@ -1479,13 +1479,12 @@ namespace BTCPayServer.Controllers
|
|||||||
var settings = GetDerivationSchemeSettings(walletId);
|
var settings = GetDerivationSchemeSettings(walletId);
|
||||||
if (settings is null)
|
if (settings is null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
var signingKeySettings = settings.GetSigningAccountKeySettings(extKey);
|
var signingKeySettings = settings.GetAccountKeySettingsFromRoot(extKey);
|
||||||
if (signingKeySettings is null)
|
if (signingKeySettings is null)
|
||||||
{
|
{
|
||||||
// Let's try best effort if RootFingerprint isn't configured, but AccountKeyPath is
|
// Let's try best effort if RootFingerprint isn't configured, but AccountKeyPath is
|
||||||
signingKeySettings = settings.AccountKeySettings
|
signingKeySettings = settings.AccountKeySettings
|
||||||
.Where(a => a.RootFingerprint is null && a.AccountKeyPath is not null)
|
.FirstOrDefault(a => a.RootFingerprint is null && a.AccountKeyPath is not null);
|
||||||
.FirstOrDefault();
|
|
||||||
if (signingKeySettings is not null)
|
if (signingKeySettings is not null)
|
||||||
signingKeySettings.RootFingerprint = extKey.GetPublicKey().GetHDFingerPrint();
|
signingKeySettings.RootFingerprint = extKey.GetPublicKey().GetHDFingerPrint();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,56 +47,55 @@ namespace BTCPayServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private BitcoinExtPubKey _signingKey;
|
[JsonIgnore]
|
||||||
|
[Obsolete("Use AccountKeySettings[0].AccountKey instead")]
|
||||||
public BitcoinExtPubKey SigningKey
|
public BitcoinExtPubKey SigningKey
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _signingKey ?? AccountKeySettings?.Select(k => k.AccountKey).FirstOrDefault();
|
// There should always be at least one account key
|
||||||
|
return AccountKeySettings[0].AccountKey;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_signingKey = value;
|
// Ignored, this is legacy stuff that should disappear
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Source { get; set; }
|
public string Source { get; set; }
|
||||||
|
|
||||||
public bool IsHotWallet { get; set; }
|
public bool IsHotWallet { get; set; }
|
||||||
|
|
||||||
[Obsolete("Use GetSigningAccountKeySettings().AccountKeyPath instead")]
|
|
||||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
public KeyPath AccountKeyPath { get; set; }
|
|
||||||
|
|
||||||
public DerivationStrategyBase AccountDerivation { get; set; }
|
public DerivationStrategyBase AccountDerivation { get; set; }
|
||||||
public string AccountOriginal { get; set; }
|
public string AccountOriginal { get; set; }
|
||||||
|
|
||||||
[Obsolete("Use GetSigningAccountKeySettings().RootFingerprint instead")]
|
|
||||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
public HDFingerprint? RootFingerprint { get; set; }
|
|
||||||
|
|
||||||
[Obsolete("Use GetSigningAccountKeySettings().AccountKey instead")]
|
|
||||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
public BitcoinExtPubKey ExplicitAccountKey { get; set; }
|
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
[Obsolete("Use GetFirstAccountKeySettings isntead")]
|
||||||
public AccountKeySettings GetSigningAccountKeySettings()
|
public AccountKeySettings GetSigningAccountKeySettings()
|
||||||
{
|
// There should always be at least one account key
|
||||||
return (AccountKeySettings ?? []).Single(a => a.AccountKey == SigningKey);
|
=> (AccountKeySettings ?? []).First();
|
||||||
}
|
|
||||||
|
|
||||||
|
public AccountKeySettings GetFirstAccountKeySettings()
|
||||||
|
// There should always be at least one account key
|
||||||
|
=> (AccountKeySettings ?? []).First();
|
||||||
|
|
||||||
|
public AccountKeySettings? GetAccountKeySettingsFromRoot(IHDKey rootKey)
|
||||||
|
=> GetAccountKeySettingsFromRoot(rootKey.GetPublicKey().GetHDFingerPrint());
|
||||||
|
|
||||||
|
public AccountKeySettings? GetAccountKeySettingsFromRoot(HDFingerprint rootFingerprint)
|
||||||
|
=> (AccountKeySettings ?? []).FirstOrDefault(a => a.RootFingerprint == rootFingerprint);
|
||||||
|
|
||||||
|
[Obsolete("Use GetAccountKeySettingsFromRoot instead")]
|
||||||
public AccountKeySettings? GetSigningAccountKeySettings(IHDKey rootKey)
|
public AccountKeySettings? GetSigningAccountKeySettings(IHDKey rootKey)
|
||||||
=> GetSigningAccountKeySettings(rootKey.GetPublicKey().GetHDFingerPrint());
|
=> GetAccountKeySettingsFromRoot(rootKey.GetPublicKey().GetHDFingerPrint());
|
||||||
|
|
||||||
|
[Obsolete("Use GetAccountKeySettingsFromRoot instead")]
|
||||||
public AccountKeySettings? GetSigningAccountKeySettings(HDFingerprint rootFingerprint)
|
public AccountKeySettings? GetSigningAccountKeySettings(HDFingerprint rootFingerprint)
|
||||||
{
|
=> GetAccountKeySettingsFromRoot(rootFingerprint);
|
||||||
return (AccountKeySettings ?? []).Where(a => a.RootFingerprint == rootFingerprint).FirstOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
[Obsolete("Use AccountKeySettings[0] instead")]
|
||||||
public AccountKeySettings? GetSigningAccountKeySettingsOrDefault()
|
// There should always be at least one account key
|
||||||
{
|
public AccountKeySettings? GetSigningAccountKeySettingsOrDefault() => this.AccountKeySettings[0];
|
||||||
return (AccountKeySettings ?? []).SingleOrDefault(a => a.AccountKey == SigningKey);
|
|
||||||
}
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
public AccountKeySettings[] AccountKeySettings { get; set; }
|
public AccountKeySettings[] AccountKeySettings { get; set; }
|
||||||
|
|
||||||
@@ -119,12 +118,12 @@ namespace BTCPayServer
|
|||||||
|
|
||||||
#region MultiSig related settings
|
#region MultiSig related settings
|
||||||
public bool IsMultiSigOnServer { get; set; }
|
public bool IsMultiSigOnServer { get; set; }
|
||||||
|
|
||||||
// some hardware devices like Jade require sending full input transactions if there are multiple inputs
|
// some hardware devices like Jade require sending full input transactions if there are multiple inputs
|
||||||
// https://github.com/Blockstream/Jade/blob/0d6ce77bf23ef2b5dc43cdae3967b4207e8cad52/main/process/sign_tx.c#L586
|
// https://github.com/Blockstream/Jade/blob/0d6ce77bf23ef2b5dc43cdae3967b4207e8cad52/main/process/sign_tx.c#L586
|
||||||
public bool DefaultIncludeNonWitnessUtxo { get; set; }
|
public bool DefaultIncludeNonWitnessUtxo { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return AccountDerivation.ToString();
|
return AccountDerivation.ToString();
|
||||||
|
|||||||
@@ -964,23 +964,6 @@ retry:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MigrateDerivationSettings(DerivationSchemeSettings s, BTCPayNetwork network)
|
|
||||||
{
|
|
||||||
if (network == null || s.AccountKeySettings is not (null or { Length: 1 }))
|
|
||||||
return;
|
|
||||||
s.AccountKeySettings = s.AccountDerivation.GetExtPubKeys().Select(e => new AccountKeySettings()
|
|
||||||
{
|
|
||||||
AccountKey = e.GetWif(network.NBitcoinNetwork),
|
|
||||||
}).ToArray();
|
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
|
||||||
s.AccountKeySettings[0].AccountKeyPath = s.AccountKeyPath;
|
|
||||||
s.AccountKeySettings[0].RootFingerprint = s.RootFingerprint;
|
|
||||||
s.ExplicitAccountKey = null;
|
|
||||||
s.AccountKeyPath = null;
|
|
||||||
s.RootFingerprint = null;
|
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task MigratePaymentMethodCriteria()
|
private async Task MigratePaymentMethodCriteria()
|
||||||
{
|
{
|
||||||
using var ctx = _DBContextFactory.CreateContext();
|
using var ctx = _DBContextFactory.CreateContext();
|
||||||
|
|||||||
@@ -21,20 +21,18 @@ namespace BTCPayServer.Models.StoreViewModels
|
|||||||
public string Label { get; set; }
|
public string Label { get; set; }
|
||||||
|
|
||||||
public string DerivationSchemeInput { get; set; }
|
public string DerivationSchemeInput { get; set; }
|
||||||
[Display(Name = "Is signing key")]
|
|
||||||
public string SelectedSigningKey { get; set; }
|
|
||||||
public bool IsMultiSig => AccountKeys.Count > 1;
|
public bool IsMultiSig => AccountKeys.Count > 1;
|
||||||
|
|
||||||
public List<WalletSettingsAccountKeyViewModel> AccountKeys { get; set; } = new();
|
public List<WalletSettingsAccountKeyViewModel> AccountKeys { get; set; } = new();
|
||||||
public bool NBXSeedAvailable { get; set; }
|
public bool NBXSeedAvailable { get; set; }
|
||||||
public string StoreName { get; set; }
|
public string StoreName { get; set; }
|
||||||
public string UriScheme { get; set; }
|
public string UriScheme { get; set; }
|
||||||
|
|
||||||
#region MultiSig related settings
|
#region MultiSig related settings
|
||||||
public bool CanSetupMultiSig { get; set; }
|
public bool CanSetupMultiSig { get; set; }
|
||||||
[Display(Name = "Is MultiSig on Server")]
|
[Display(Name = "Is MultiSig on Server")]
|
||||||
public bool IsMultiSigOnServer { get; set; }
|
public bool IsMultiSigOnServer { get; set; }
|
||||||
|
|
||||||
// some hardware devices like Jade require sending full input transactions if there are multiple inputs
|
// some hardware devices like Jade require sending full input transactions if there are multiple inputs
|
||||||
// https://github.com/Blockstream/Jade/blob/0d6ce77bf23ef2b5dc43cdae3967b4207e8cad52/main/process/sign_tx.c#L586
|
// https://github.com/Blockstream/Jade/blob/0d6ce77bf23ef2b5dc43cdae3967b4207e8cad52/main/process/sign_tx.c#L586
|
||||||
[Display(Name = "Default Include NonWitness Utxo in PSBTs")]
|
[Display(Name = "Default Include NonWitness Utxo in PSBTs")]
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ namespace BTCPayServer.Payments.Bitcoin
|
|||||||
public Task ValidatePaymentMethodConfig(PaymentMethodConfigValidationContext validationContext)
|
public Task ValidatePaymentMethodConfig(PaymentMethodConfigValidationContext validationContext)
|
||||||
{
|
{
|
||||||
var parser = Network.GetDerivationSchemeParser();
|
var parser = Network.GetDerivationSchemeParser();
|
||||||
DerivationSchemeSettings settings = new DerivationSchemeSettings();
|
var settings = new DerivationSchemeSettings();
|
||||||
if (validationContext.Config is JValue { Type: JTokenType.String, Value: string config }
|
if (validationContext.Config is JValue { Type: JTokenType.String, Value: string config }
|
||||||
&& parser.TryParseXpub(config, ref settings))
|
&& parser.TryParseXpub(config, ref settings))
|
||||||
{
|
{
|
||||||
@@ -287,17 +287,15 @@ namespace BTCPayServer.Payments.Bitcoin
|
|||||||
{
|
{
|
||||||
validationContext.ModelState.AddModelError(nameof(res.AccountDerivation), "Invalid account derivation");
|
validationContext.ModelState.AddModelError(nameof(res.AccountDerivation), "Invalid account derivation");
|
||||||
}
|
}
|
||||||
if (res.AccountKeySettings is null)
|
if (res.AccountKeySettings is null || res.AccountKeySettings.Length == 0)
|
||||||
{
|
{
|
||||||
validationContext.ModelState.AddModelError(nameof(res.AccountKeySettings), "Invalid AccountKeySettings");
|
validationContext.ModelState.AddModelError(nameof(res.AccountKeySettings), "Invalid AccountKeySettings");
|
||||||
}
|
}
|
||||||
if (res.SigningKey is null)
|
|
||||||
|
foreach (var acc in res.AccountKeySettings ?? [])
|
||||||
{
|
{
|
||||||
validationContext.ModelState.AddModelError(nameof(res.SigningKey), "Invalid SigningKey");
|
if (acc.AccountKey is null)
|
||||||
}
|
validationContext.ModelState.AddModelError(nameof(res.AccountKeySettings), "Missing AccountKey");
|
||||||
if (res.GetSigningAccountKeySettingsOrDefault() is null)
|
|
||||||
{
|
|
||||||
validationContext.ModelState.AddModelError(nameof(res.AccountKeySettings), "AccountKeySettings doesn't include the SigningKey");
|
|
||||||
}
|
}
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Linq;
|
||||||
using BTCPayServer.BIP78.Sender;
|
using BTCPayServer.BIP78.Sender;
|
||||||
using NBitcoin;
|
using NBitcoin;
|
||||||
|
|
||||||
@@ -10,7 +11,11 @@ namespace BTCPayServer.Payments.PayJoin.Sender
|
|||||||
public PayjoinWallet(DerivationSchemeSettings derivationSchemeSettings)
|
public PayjoinWallet(DerivationSchemeSettings derivationSchemeSettings)
|
||||||
{
|
{
|
||||||
_derivationSchemeSettings = derivationSchemeSettings;
|
_derivationSchemeSettings = derivationSchemeSettings;
|
||||||
|
AccountSettings = _derivationSchemeSettings.AccountKeySettings.Single();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AccountKeySettings AccountSettings { get; set; }
|
||||||
|
|
||||||
public IHDScriptPubKey Derive(KeyPath keyPath)
|
public IHDScriptPubKey Derive(KeyPath keyPath)
|
||||||
{
|
{
|
||||||
return ((IHDScriptPubKey)_derivationSchemeSettings.AccountDerivation).Derive(keyPath);
|
return ((IHDScriptPubKey)_derivationSchemeSettings.AccountDerivation).Derive(keyPath);
|
||||||
@@ -25,8 +30,8 @@ namespace BTCPayServer.Payments.PayJoin.Sender
|
|||||||
public ScriptPubKeyType ScriptPubKeyType => _derivationSchemeSettings.AccountDerivation.ScriptPubKeyType();
|
public ScriptPubKeyType ScriptPubKeyType => _derivationSchemeSettings.AccountDerivation.ScriptPubKeyType();
|
||||||
|
|
||||||
public RootedKeyPath RootedKeyPath =>
|
public RootedKeyPath RootedKeyPath =>
|
||||||
_derivationSchemeSettings.GetSigningAccountKeySettings().GetRootedKeyPath();
|
AccountSettings.GetRootedKeyPath();
|
||||||
|
|
||||||
public IHDKey AccountKey => _derivationSchemeSettings.GetSigningAccountKeySettings().AccountKey;
|
public IHDKey AccountKey => AccountSettings.AccountKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a class="btn btn-secondary" asp-controller="UIWallets" asp-action="WalletLabels"
|
<a class="btn btn-secondary" asp-controller="UIWallets" asp-action="WalletLabels"
|
||||||
asp-route-walletId="@Model.WalletId" text-translate="true">Manage labels</a>
|
asp-route-walletId="@Model.WalletId" text-translate="true">Manage labels</a>
|
||||||
|
|
||||||
@@ -173,13 +173,6 @@
|
|||||||
<input asp-for="@Model.AccountKeys[i].AccountKeyPath" class="form-control" style="max-width:16ch;" />
|
<input asp-for="@Model.AccountKeys[i].AccountKeyPath" class="form-control" style="max-width:16ch;" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@if (Model is { IsMultiSig: true, IsMultiSigOnServer: false })
|
|
||||||
{
|
|
||||||
<div class="form-check">
|
|
||||||
<input asp-for="SelectedSigningKey" class="form-check-input" type="radio" value="@Model.AccountKeys[i].AccountKey" />
|
|
||||||
<label asp-for="SelectedSigningKey" class="form-check-label"></label>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@@ -190,14 +183,14 @@
|
|||||||
<script>
|
<script>
|
||||||
const wallets = @Safe.Json(Model.AccountKeys.Select(model => Encoders.Hex.EncodeData(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(model, Formatting.None)))))
|
const wallets = @Safe.Json(Model.AccountKeys.Select(model => Encoders.Hex.EncodeData(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(model, Formatting.None)))))
|
||||||
const qrApp = initQRShow({ title: "Wallet QR" })
|
const qrApp = initQRShow({ title: "Wallet QR" })
|
||||||
|
|
||||||
delegate('click', '#Delete', event => { event.preventDefault() })
|
delegate('click', '#Delete', event => { event.preventDefault() })
|
||||||
|
|
||||||
delegate('click', 'button[data-account-key]', event => {
|
delegate('click', 'button[data-account-key]', event => {
|
||||||
const { accountKey } = event.target.dataset;
|
const { accountKey } = event.target.dataset;
|
||||||
qrApp.showData(wallets[parseInt(accountKey)]);
|
qrApp.showData(wallets[parseInt(accountKey)]);
|
||||||
})
|
})
|
||||||
|
|
||||||
if (navigator.registerProtocolHandler) {
|
if (navigator.registerProtocolHandler) {
|
||||||
document.getElementById('RegisterWallet').removeAttribute('hidden');
|
document.getElementById('RegisterWallet').removeAttribute('hidden');
|
||||||
delegate('click', '#RegisterWallet', event => {
|
delegate('click', '#RegisterWallet', event => {
|
||||||
@@ -205,7 +198,7 @@
|
|||||||
const uri = decodeURIComponent(url)
|
const uri = decodeURIComponent(url)
|
||||||
navigator.registerProtocolHandler(scheme, uri, `BTCPay Wallet: ${store}`)
|
navigator.registerProtocolHandler(scheme, uri, `BTCPay Wallet: ${store}`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<partial name="_ValidationScriptsPartial"/>
|
<partial name="_ValidationScriptsPartial"/>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user