Show proper error message if the keypath in wallet settings is not good (Fix #1209)

This commit is contained in:
nicolas.dorier
2019-12-03 14:26:52 +09:00
parent 71a8166027
commit a3fc75ea3b
3 changed files with 24 additions and 16 deletions

View File

@@ -138,6 +138,19 @@ namespace BTCPayServer.Controllers
await websocketHelper.Send("{ \"error\": \"wrong-wallet\"}", cancellationToken);
continue;
}
var signableInputs = psbt.Inputs
.SelectMany(i => i.HDKeyPaths)
.Where(i => i.Value.MasterFingerprint == fingerprint)
.ToArray();
if (signableInputs.Length > 0)
{
var actualPubKey = (await device.GetXPubAsync(signableInputs[0].Value.KeyPath)).GetPublicKey();
if (actualPubKey != signableInputs[0].Key)
{
await websocketHelper.Send("{ \"error\": \"wrong-keypath\"}", cancellationToken);
continue;
}
}
try
{
psbt = await device.SignPSBTAsync(psbt, cancellationToken);