示例#1
0
 public static Gen <Transaction> TX(Network network) =>
 from version in Gen.Choose(0, Int32.MaxValue)
 from inputs in NonEmptyInputs()
 from outputs in NonEmptyOutputs()
 from locktime in PrimitiveGenerator.UInt32()
 let tx = LegacyTransactionGenerators.ComposeTx(Transaction.Create(network), inputs, outputs, locktime)
              where tx.HasWitness
          select tx;
 /// <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;
示例#3
0
 public static Gen <TxIn> WitnessInput() =>
 from txin in LegacyTransactionGenerators.Input()
 from witscript in ScriptGenerator.RandomWitScript()
 select AttachWitScript(txin, witscript);