public static Gen <TxIn> Input() => from prevout in OutPoint()
 from ss in ScriptGenerator.RandomScriptSig()
 from nSequence in PrimitiveGenerator.UInt32()
 select new TxIn(prevout, ss)
 {
     Sequence = nSequence
 };
Пример #2
0
 /// <summary>
 /// This is slow, provably because `Add*` methods will iterate over inputs.
 /// </summary>
 /// <param name="network"></param>
 /// <returns></returns>
 public static Gen <PSBT> SanePSBT(Network network) =>
 from inputN in Gen.Choose(0, 8)
 from scripts in Gen.ListOf(inputN, ScriptGenerator.RandomScriptSig())
 from txOuts in Gen.Sequence(scripts.Select(sc => OutputFromRedeem(sc)))
 from prevN in Gen.Choose(0, 5)
 from prevTxs in Gen.Sequence(txOuts.Select(o => TXFromOutput(o, network, prevN)))
 let txins = prevTxs.Select(tx => new TxIn(new OutPoint(tx.GetHash(), prevN)))
             from locktime in PrimitiveGenerator.UInt32()
             let tx = LegacyTransactionGenerators.ComposeTx(network.CreateTransaction(), txins.ToList(), txOuts.ToList(), locktime)
                      from TxsToAdd in Gen.SubListOf(prevTxs)
                      from CoinsToAdd in Gen.SubListOf(prevTxs.SelectMany(tx => tx.Outputs.AsCoins()))
                      from scriptsToAdd in Gen.SubListOf <Script>(scripts)
                      let psbt = tx.CreatePSBT(network)
                                 .AddTransactions(prevTxs.ToArray())
                                 .AddCoins(CoinsToAdd.ToArray())
                                 .AddScripts(scriptsToAdd.ToArray())
                                 select psbt;