Add overloads to SignAll and GetBalance PSBT
This commit is contained in:
parent
e494a46de9
commit
cdac2c264e
@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;netstandard2.1</TargetFrameworks>
|
||||
<Company>Digital Garage</Company>
|
||||
<Version>5.0.1</Version>
|
||||
<Version>5.0.2</Version>
|
||||
<Copyright>Copyright © Digital Garage 2017</Copyright>
|
||||
<Description>Client API for the minimalist HD Wallet Tracker NBXplorer</Description>
|
||||
<PackageIcon>Bitcoin.png</PackageIcon>
|
||||
|
||||
@ -6,28 +6,65 @@ namespace NBitcoin;
|
||||
|
||||
public static class NBitcoinNBXplorerExtensions
|
||||
{
|
||||
public static Money GetBalance(this PSBT psbt, DerivationStrategyBase derivationStrategy, IHDKey accountKey)
|
||||
/// <summary>
|
||||
/// Get the balance change if you were signing this transaction.
|
||||
/// </summary>
|
||||
/// <param name="psbt">The PSBT from which to get the balance</param>
|
||||
/// <param name="derivationStrategy">The derivation scheme</param>
|
||||
/// <param name="accountKey">The account key that will be used to sign (i.e., 49'/0'/0')</param>
|
||||
/// <param name="accountKeyPath">The account key path</param>
|
||||
/// <returns>The balance change</returns>
|
||||
public static Money GetBalance(this PSBT psbt, DerivationStrategyBase derivationStrategy, IHDKey accountKey, RootedKeyPath? accountKeyPath)
|
||||
{
|
||||
if (derivationStrategy is null)
|
||||
throw new ArgumentNullException(nameof(derivationStrategy));
|
||||
if (derivationStrategy is StandardDerivationStrategyBase standard)
|
||||
return psbt.GetBalance(standard, accountKey);
|
||||
return psbt.GetBalance(standard, accountKey, accountKeyPath);
|
||||
#if !NO_RECORD
|
||||
else if (derivationStrategy is PolicyDerivationStrategy policy && policy.GetHDScriptPubKey(accountKey) is IHDScriptPubKey hd)
|
||||
return psbt.GetBalance(hd, accountKey);
|
||||
return psbt.GetBalance(hd, accountKey, accountKeyPath);
|
||||
#endif
|
||||
return Money.Zero;
|
||||
}
|
||||
public static PSBT SignAll(this PSBT psbt, DerivationStrategyBase derivationStrategy, IHDKey accountKey)
|
||||
|
||||
/// <summary>
|
||||
/// Get the balance change if you were signing this transaction.
|
||||
/// </summary>
|
||||
/// <param name="psbt">The PSBT from which to get the balance</param>
|
||||
/// <param name="derivationStrategy">The derivation scheme</param>
|
||||
/// <param name="accountKey">The account key that will be used to sign (i.e., 49'/0'/0')</param>
|
||||
/// <returns>The balance change</returns>
|
||||
public static Money GetBalance(this PSBT psbt, DerivationStrategyBase derivationStrategy, IHDKey accountKey)
|
||||
=> GetBalance(psbt, derivationStrategy, accountKey, null);
|
||||
|
||||
/// <summary>
|
||||
/// Sign all inputs that derive addresses from <paramref name="derivationStrategy"/> and that need to be signed by <paramref name="accountKey"/>.
|
||||
/// </summary>
|
||||
/// <param name="psbt">The PSBT to sign</param>
|
||||
/// <param name="derivationStrategy">The derivation scheme</param>
|
||||
/// <param name="accountKey">The account key with which to sign</param>
|
||||
/// <param name="accountKeyPath">The account key path (eg. [masterFP]/49'/0'/0')</param>
|
||||
/// <returns>The signed PSBT</returns>
|
||||
public static PSBT SignAll(this PSBT psbt, DerivationStrategyBase derivationStrategy, IHDKey accountKey, RootedKeyPath? accountKeyPath)
|
||||
{
|
||||
if (derivationStrategy is null)
|
||||
throw new ArgumentNullException(nameof(derivationStrategy));
|
||||
if (derivationStrategy is StandardDerivationStrategyBase standard)
|
||||
return psbt.SignAll(standard, accountKey);
|
||||
return psbt.SignAll(standard, accountKey, accountKeyPath);
|
||||
#if !NO_RECORD
|
||||
else if (derivationStrategy is PolicyDerivationStrategy policy && policy.GetHDScriptPubKey(accountKey) is IHDScriptPubKey hd)
|
||||
return psbt.SignAll(hd, accountKey);
|
||||
return psbt.SignAll(hd, accountKey, accountKeyPath);
|
||||
#endif
|
||||
return psbt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sign all inputs that derive addresses from <paramref name="derivationStrategy"/> and that need to be signed by <paramref name="accountKey"/>.
|
||||
/// </summary>
|
||||
/// <param name="psbt">The PSBT to sign</param>
|
||||
/// <param name="derivationStrategy">The derivation scheme</param>
|
||||
/// <param name="accountKey">The account key with which to sign</param>
|
||||
/// <returns>The signed PSBT</returns>
|
||||
public static PSBT SignAll(this PSBT psbt, DerivationStrategyBase derivationStrategy, IHDKey accountKey)
|
||||
=> SignAll(psbt, derivationStrategy, accountKey, null);
|
||||
}
|
||||
4
NBXplorer.sln.DotSettings
Normal file
4
NBXplorer.sln.DotSettings
Normal file
@ -0,0 +1,4 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=psbt/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=NBXplorer/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Xplorer/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
Loading…
Reference in New Issue
Block a user