Always rebase keys before signing, refacotring some code

This commit is contained in:
nicolas.dorier
2019-05-12 11:07:41 +09:00
parent b214e3f6df
commit ff82f15246
2 changed files with 42 additions and 25 deletions

View File

@@ -143,6 +143,19 @@ namespace BTCPayServer
}
}
public IEnumerable<NBXplorer.Models.PSBTRebaseKeyRules> GetPSBTRebaseKeyRules()
{
if (AccountKey != null && AccountKeyPath != null && RootFingerprint is HDFingerprint fp)
{
yield return new NBXplorer.Models.PSBTRebaseKeyRules()
{
AccountKey = AccountKey,
AccountKeyPath = AccountKeyPath,
MasterFingerprint = fp
};
}
}
public string Label { get; set; }
[JsonIgnore]
@@ -163,5 +176,13 @@ namespace BTCPayServer
{
return Network.NBXplorerNetwork.Serializer.ToString(this);
}
public void RebaseKeyPaths(PSBT psbt)
{
foreach (var rebase in GetPSBTRebaseKeyRules())
{
psbt.RebaseKeyPaths(rebase.AccountKey, rebase.AccountKeyPath, rebase.MasterFingerprint);
}
}
}
}