mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Can update PSBT, fix the PSBT review page
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.9" />
|
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.9" />
|
||||||
<PackageReference Include="NBitcoin" Version="4.1.2.32" />
|
<PackageReference Include="NBitcoin" Version="4.1.2.35" />
|
||||||
<PackageReference Include="NBXplorer.Client" Version="2.0.0.16" />
|
<PackageReference Include="NBXplorer.Client" Version="2.0.0.17" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ services:
|
|||||||
|
|
||||||
|
|
||||||
nbxplorer:
|
nbxplorer:
|
||||||
image: nicolasdorier/nbxplorer:2.0.0.45
|
image: nicolasdorier/nbxplorer:2.0.0.48
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "32838:32838"
|
- "32838:32838"
|
||||||
|
|||||||
@@ -86,6 +86,20 @@ namespace BTCPayServer.Controllers
|
|||||||
return View(vm);
|
return View(vm);
|
||||||
case "ledger":
|
case "ledger":
|
||||||
return ViewWalletSendLedger(psbt);
|
return ViewWalletSendLedger(psbt);
|
||||||
|
case "update":
|
||||||
|
var derivationSchemeSettings = await GetDerivationSchemeSettings(walletId);
|
||||||
|
psbt = await UpdatePSBT(derivationSchemeSettings, psbt, network);
|
||||||
|
if (psbt == null)
|
||||||
|
{
|
||||||
|
StatusMessage = "Error: You need to update NBXplorer";
|
||||||
|
return View(vm);
|
||||||
|
}
|
||||||
|
ModelState.Remove(nameof(vm.PSBT));
|
||||||
|
ModelState.Remove(nameof(vm.UploadedPSBTFile));
|
||||||
|
vm.PSBT = psbt.ToBase64();
|
||||||
|
vm.Decoded = psbt.ToString();
|
||||||
|
StatusMessage = "PSBT updated!";
|
||||||
|
return View(vm);
|
||||||
case "seed":
|
case "seed":
|
||||||
return SignWithSeed(walletId, psbt.ToBase64());
|
return SignWithSeed(walletId, psbt.ToBase64());
|
||||||
case "broadcast":
|
case "broadcast":
|
||||||
@@ -102,6 +116,19 @@ namespace BTCPayServer.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<PSBT> UpdatePSBT(DerivationSchemeSettings derivationSchemeSettings, PSBT psbt, BTCPayNetwork network)
|
||||||
|
{
|
||||||
|
var result = await ExplorerClientProvider.GetExplorerClient(network).UpdatePSBTAsync(new UpdatePSBTRequest()
|
||||||
|
{
|
||||||
|
PSBT = psbt,
|
||||||
|
DerivationScheme = derivationSchemeSettings.AccountDerivation,
|
||||||
|
});
|
||||||
|
if (result == null)
|
||||||
|
return null;
|
||||||
|
derivationSchemeSettings.RebaseKeyPaths(result.PSBT);
|
||||||
|
return result.PSBT;
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("{walletId}/psbt/ready")]
|
[Route("{walletId}/psbt/ready")]
|
||||||
public async Task<IActionResult> WalletPSBTReady(
|
public async Task<IActionResult> WalletPSBTReady(
|
||||||
@@ -122,12 +149,12 @@ namespace BTCPayServer.Controllers
|
|||||||
return View(nameof(WalletPSBTReady), vm);
|
return View(nameof(WalletPSBTReady), vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task FetchTransactionDetails(DerivationSchemeSettings derivationSchemeSettings, WalletPSBTReadyViewModel vm, BTCPayNetwork network)
|
private async Task FetchTransactionDetails(DerivationSchemeSettings derivationSchemeSettings, WalletPSBTReadyViewModel vm, BTCPayNetwork network)
|
||||||
{
|
{
|
||||||
var psbtObject = PSBT.Parse(vm.PSBT, network.NBitcoinNetwork);
|
var psbtObject = PSBT.Parse(vm.PSBT, network.NBitcoinNetwork);
|
||||||
|
psbtObject = await UpdatePSBT(derivationSchemeSettings, psbtObject, network) ?? psbtObject;
|
||||||
IHDKey signingKey = null;
|
IHDKey signingKey = null;
|
||||||
RootedKeyPath signingKeyPath = null;
|
RootedKeyPath signingKeyPath = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
signingKey = new BitcoinExtPubKey(vm.SigningKey, network.NBitcoinNetwork);
|
signingKey = new BitcoinExtPubKey(vm.SigningKey, network.NBitcoinNetwork);
|
||||||
@@ -203,7 +230,6 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
vm.SetErrors(errors);
|
vm.SetErrors(errors);
|
||||||
}
|
}
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|||||||
@@ -27,19 +27,28 @@
|
|||||||
<h3>Decoded PSBT</h3>
|
<h3>Decoded PSBT</h3>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<form method="post" asp-action="WalletPSBT">
|
<form method="post" asp-action="WalletPSBT">
|
||||||
|
<input type="hidden" asp-for="PSBT" />
|
||||||
|
<input type="hidden" asp-for="FileName" />
|
||||||
<div class="dropdown" style="margin-top:16px;">
|
<div class="dropdown" style="margin-top:16px;">
|
||||||
<button class="btn btn-primary dropdown-toggle" type="button" id="SendMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<button class="btn btn-primary dropdown-toggle" type="button" id="SendMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
Sign with...
|
Sign with...
|
||||||
</button>
|
</button>
|
||||||
<input type="hidden" asp-for="PSBT" />
|
|
||||||
<input type="hidden" asp-for="FileName" />
|
|
||||||
<div class="dropdown-menu" aria-labelledby="SendMenu">
|
<div class="dropdown-menu" aria-labelledby="SendMenu">
|
||||||
<button name="command" type="submit" class="dropdown-item" value="ledger">... your Ledger Wallet device</button>
|
<button name="command" type="submit" class="dropdown-item" value="ledger">... your Ledger Wallet device</button>
|
||||||
<button name="command" type="submit" class="dropdown-item" value="seed">... an HD private key or mnemonic seed</button>
|
<button name="command" type="submit" class="dropdown-item" value="seed">... an HD private key or mnemonic seed</button>
|
||||||
<button name="command" type="submit" class="dropdown-item" value="save-psbt">... a wallet supporting PSBT (save as file)</button>
|
<button name="command" type="submit" class="dropdown-item" value="save-psbt">... a wallet supporting PSBT (save as file)</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dropdown" style="margin-top:16px;">
|
||||||
|
<button class="btn btn-primary dropdown-toggle" type="button" id="OtherActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
Other actions...
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-menu" aria-labelledby="OtherActions">
|
||||||
<button name="command" type="submit" class="btn btn-secondary" value="broadcast">Review</button>
|
<button name="command" type="submit" class="btn btn-secondary" value="broadcast">Review</button>
|
||||||
<button name="command" type="submit" class="btn btn-secondary" value="combine">Combine with another PSBT</button>
|
<button name="command" type="submit" class="btn btn-secondary" value="update">Update</button>
|
||||||
|
<button name="command" type="submit" class="btn btn-secondary" value="combine">Combine</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user