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
 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;
コード例 #3
0
ファイル: PSBTGenerator.cs プロジェクト: wbband/NBitcoin
 /// <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()
                                 .AddTransactions(prevTxs.ToArray())
                                 .AddCoins(CoinsToAdd.ToArray())
                                 .AddScripts(scriptsToAdd.ToArray())
                                 select psbt;
コード例 #4
0
 public static Gen <HDKeyPathKVMap> HDKeyPaths(IEnumerable <PubKey> pks, int itemNum) =>
 from MasterKeyFingerPrints in Gen.ListOf(itemNum, PrimitiveGenerator.UInt32())
 from paths in Gen.ListOf(itemNum, CryptoGenerator.KeyPath())
 let fingerPrintAndPath = MasterKeyFingerPrints.ToArray().Zip(paths.ToArray(), (m, p) => Tuple.Create(m, p)).ToList()
                          select Utils.DictionaryFromList <PubKey, Tuple <uint, KeyPath> >(pks.ToList(), fingerPrintAndPath);
 public static Gen <Transaction> TX(Network network) =>
 from version in Gen.Choose(0, Int32.MaxValue)
 from txin in NonEmptyInputs()
 from txout in NonEmptyOutputs()
 from locktime in PrimitiveGenerator.UInt32()
 select ComposeTx(Transaction.Create(network), txin, txout, locktime);
コード例 #6
0
 public static Gen <HDFingerprint> HDFingerPrint() =>
 from x in PrimitiveGenerator.UInt32()
 select new HDFingerprint(x);