本文整理匯總了C#中NBitcoin.Transaction.ToDictionary方法的典型用法代碼示例。如果您正苦於以下問題:C# Transaction.ToDictionary方法的具體用法?C# Transaction.ToDictionary怎麽用?C# Transaction.ToDictionary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NBitcoin.Transaction
的用法示例。
在下文中一共展示了Transaction.ToDictionary方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SignTransaction
public Transaction SignTransaction(KeyPath keyPath, ICoin[] signedCoins, Transaction[] parents, Transaction transaction)
{
using(Transport.Lock())
{
var pubkey = GetWalletPubKey(keyPath).UncompressedPublicKey.Compress();
var parentsById = parents.ToDictionary(p => p.GetHash());
var coinsByPrevout = signedCoins.ToDictionary(c => c.Outpoint);
List<TrustedInput> trustedInputs = new List<TrustedInput>();
foreach(var input in transaction.Inputs)
{
Transaction parent;
parentsById.TryGetValue(input.PrevOut.Hash, out parent);
if(parent == null)
throw new KeyNotFoundException("Parent transaction " + input.PrevOut.Hash + " not found");
trustedInputs.Add(GetTrustedInput(parent, (int)input.PrevOut.N));
}
var inputs = trustedInputs.ToArray();
transaction = transaction.Clone();
foreach(var input in transaction.Inputs)
{
ICoin previousCoin = null;
coinsByPrevout.TryGetValue(input.PrevOut, out previousCoin);
if(previousCoin != null)
input.ScriptSig = previousCoin.GetScriptCode();
}
bool newTransaction = true;
foreach(var input in transaction.Inputs.AsIndexedInputs())
{
ICoin coin = null;
if(!coinsByPrevout.TryGetValue(input.PrevOut, out coin))
continue;
UntrustedHashTransactionInputStart(newTransaction, input, inputs);
newTransaction = false;
UntrustedHashTransactionInputFinalizeFull(transaction.Outputs);
var sig = UntrustedHashSign(keyPath, null, transaction.LockTime, SigHash.All);
input.ScriptSig = PayToPubkeyHashTemplate.Instance.GenerateScriptSig(sig, pubkey);
ScriptError error;
if(!Script.VerifyScript(coin.TxOut.ScriptPubKey, transaction, (int)input.Index, Money.Zero, out error))
return null;
}
return transaction;
}
}