/// <summary> /// Filter the coins which contains a HD Key path matching this masterFingerprint/account key /// </summary> /// <param name="masterFingerprint">The master root fingerprint</param> /// <param name="accountKey">The account key (ie. 49'/0'/0')</param> /// <returns>Inputs with HD keys matching masterFingerprint and account key</returns> public IEnumerable <PSBTCoin> CoinsFor(HDFingerprint?masterFingerprint, IHDKey accountKey) { if (accountKey == null) { throw new ArgumentNullException(nameof(accountKey)); } return(Inputs.CoinsFor(masterFingerprint, accountKey).OfType <PSBTCoin>().Concat(Outputs.CoinsFor(masterFingerprint, accountKey).OfType <PSBTCoin>())); }
/// <summary> /// Filter the coins which contains a HD Key path matching this master root key /// </summary> /// <param name="masterKey">The master root key</param> /// <returns>Inputs with HD keys matching master root key</returns> public IEnumerable <PSBTCoin> CoinsFor(IHDKey masterKey) { if (masterKey == null) { throw new ArgumentNullException(nameof(masterKey)); } return(Inputs.CoinsFor(masterKey).OfType <PSBTCoin>().Concat(Outputs.CoinsFor(masterKey).OfType <PSBTCoin>())); }
/// <summary> /// Filter the coins which contains the <paramref name="accountKey"/> and <paramref name="accountKeyPath"/> in the HDKeys and derive /// the same scriptPubKeys as <paramref name="accountHDScriptPubKey"/>. /// </summary> /// <param name="accountHDScriptPubKey">The hdScriptPubKey used to generate addresses</param> /// <param name="accountKey">The account key that will be used to sign (ie. 49'/0'/0')</param> /// <param name="accountKeyPath">The account key path</param> /// <returns>Inputs with HD keys matching masterFingerprint and account key</returns> public IEnumerable <PSBTCoin> CoinsFor(IHDScriptPubKey accountHDScriptPubKey, IHDKey accountKey, RootedKeyPath accountKeyPath = null) { if (accountKey == null) { throw new ArgumentNullException(nameof(accountKey)); } if (accountHDScriptPubKey == null) { throw new ArgumentNullException(nameof(accountHDScriptPubKey)); } accountHDScriptPubKey = accountHDScriptPubKey.AsHDKeyCache(); accountKey = accountKey.AsHDKeyCache(); return(Inputs.CoinsFor(accountHDScriptPubKey, accountKey, accountKeyPath).OfType <PSBTCoin>().Concat(Outputs.CoinsFor(accountHDScriptPubKey, accountKey, accountKeyPath).OfType <PSBTCoin>())); }
/// <summary> /// Sign all inputs which derive addresses from <paramref name="accountHDScriptPubKey"/> and that need to be signed by <paramref name="accountKey"/>. /// </summary> /// <param name="accountHDScriptPubKey">The address generator</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> /// <param name="sigHash">The SigHash</param> /// <returns>This PSBT</returns> public PSBT SignAll(IHDScriptPubKey accountHDScriptPubKey, IHDKey accountKey, RootedKeyPath accountKeyPath, SigHash sigHash = SigHash.All) { if (accountKey == null) { throw new ArgumentNullException(nameof(accountKey)); } if (accountHDScriptPubKey == null) { throw new ArgumentNullException(nameof(accountHDScriptPubKey)); } accountHDScriptPubKey = accountHDScriptPubKey.AsHDKeyCache(); accountKey = accountKey.AsHDKeyCache(); Money total = Money.Zero; foreach (var o in Inputs.CoinsFor(accountHDScriptPubKey, accountKey, accountKeyPath)) { o.TrySign(accountHDScriptPubKey, accountKey, accountKeyPath, sigHash); } return(this); }