Sign with NBX Seed (#1218)

This commit is contained in:
Andrew Camilleri
2020-01-21 09:33:12 +01:00
committed by Nicolas Dorier
parent 6848482999
commit 8e6f43cd3a
7 changed files with 85 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ using BTCPayServer.ModelBinders;
using BTCPayServer.Models.WalletViewModels;
using Microsoft.AspNetCore.Mvc;
using NBitcoin;
using NBXplorer;
using NBXplorer.Models;
namespace BTCPayServer.Controllers
@@ -56,6 +57,9 @@ namespace BTCPayServer.Controllers
{
var network = NetworkProvider.GetNetwork<BTCPayNetwork>(walletId.CryptoCode);
vm.CryptoCode = network.CryptoCode;
vm.NBXSeedAvailable = await CanUseHotWallet() && !string.IsNullOrEmpty(await ExplorerClientProvider.GetExplorerClient(network)
.GetMetadataAsync<string>(GetDerivationSchemeSettings(walletId).AccountDerivation,
WellknownMetadataKeys.Mnemonic));
if (await vm.GetPSBT(network.NBitcoinNetwork) is PSBT psbt)
{
vm.Decoded = psbt.ToString();
@@ -106,6 +110,16 @@ namespace BTCPayServer.Controllers
return RedirectToWalletPSBT(walletId, psbt, vm.FileName);
case "seed":
return SignWithSeed(walletId, psbt.ToBase64());
case "nbx-seed":
var derivationScheme = GetDerivationSchemeSettings(walletId);
var extKey = await ExplorerClientProvider.GetExplorerClient(network)
.GetMetadataAsync<string>(derivationScheme.AccountDerivation, WellknownMetadataKeys.MasterHDKey);
return await SignWithSeed(walletId, new SignWithSeedViewModel()
{
SeedOrKey = extKey,
PSBT = psbt.ToBase64()
});
case "broadcast":
{
return await WalletPSBTReady(walletId, psbt.ToBase64());