当前位置: 首页>>代码示例>>C#>>正文


C# Transaction.AddInput方法代码示例

本文整理汇总了C#中Transaction.AddInput方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.AddInput方法的具体用法?C# Transaction.AddInput怎么用?C# Transaction.AddInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transaction的用法示例。


在下文中一共展示了Transaction.AddInput方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanSignTransaction

		public void CanSignTransaction()
		{
			var key = new Key();
			var scriptPubKey = PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(key.PubKey);

			Transaction tx = new Transaction();
			tx.AddInput(new TxIn(new OutPoint(tx.GetHash(), 0))
			{
				ScriptSig = scriptPubKey
			});
			tx.AddInput(new TxIn(new OutPoint(tx.GetHash(), 1))
			{
				ScriptSig = scriptPubKey
			});
			tx.AddOutput(new TxOut("21", key.PubKey.Hash));
			var clone = tx.Clone();
			tx.Sign(key, false);
			AssertCorrectlySigned(tx, scriptPubKey);
			clone.Sign(key, true);
			AssertCorrectlySigned(clone, scriptPubKey.Hash.ScriptPubKey);
		}
开发者ID:ehsansajjad465,项目名称:NBitcoin,代码行数:21,代码来源:transaction_tests.cs

示例2: CreateFakeTx

 public static Transaction CreateFakeTx(NetworkParameters @params, ulong nanocoins, Address to)
 {
     var t = new Transaction(@params);
     var o1 = new TransactionOutput(@params, t, nanocoins, to);
     t.AddOutput(o1);
     // Make a previous tx simply to send us sufficient coins. This prev tx is not really valid but it doesn't
     // matter for our purposes.
     var prevTx = new Transaction(@params);
     var prevOut = new TransactionOutput(@params, prevTx, nanocoins, to);
     prevTx.AddOutput(prevOut);
     // Connect it.
     t.AddInput(prevOut);
     return t;
 }
开发者ID:TangibleCryptography,项目名称:BitSharper,代码行数:14,代码来源:TestUtils.cs

示例3: EmitMoney

 public Transaction EmitMoney(IDestination destination, Money amount, bool isCoinbase = true, bool indexBalance = false)
 {
     Transaction transaction = new Transaction();
     if (isCoinbase)
         transaction.AddInput(new TxIn()
         {
             ScriptSig = new Script(NoRandom ? new uint256(0).ToBytes() : RandomUtils.GetBytes(32)),
         });
     transaction.AddOutput(new TxOut()
     {
         ScriptPubKey = destination.ScriptPubKey,
         Value = amount
     });
     Add(transaction, indexBalance);
     return transaction;
 }
开发者ID:bijakatlykkex,项目名称:NBitcoin.Indexer,代码行数:16,代码来源:ChainBuilder.cs

示例4: CreateCreditingTransaction

		private static Transaction CreateCreditingTransaction(Script scriptPubKey)
		{
			var creditingTransaction = new Transaction();
			creditingTransaction.AddInput(new TxIn()
			{
				ScriptSig = new Script(OpcodeType.OP_0, OpcodeType.OP_0)
			});
			creditingTransaction.AddOutput(Money.Zero, scriptPubKey);
			return creditingTransaction;
		}
开发者ID:vebin,项目名称:NBitcoin,代码行数:10,代码来源:script_tests.cs

示例5: CreateSpendingTransaction

		private static Transaction CreateSpendingTransaction(Script scriptSig, Transaction creditingTransaction)
		{
			var spendingTransaction = new Transaction();
			spendingTransaction.AddInput(new TxIn(new OutPoint(creditingTransaction, 0))
			{
				ScriptSig = scriptSig
			});
			spendingTransaction.AddOutput(new TxOut()
			{
				ScriptPubKey = new Script(),
				Value = Money.Zero
			});
			return spendingTransaction;
		}
开发者ID:vebin,项目名称:NBitcoin,代码行数:14,代码来源:script_tests.cs

示例6: witnessHasPushSizeLimit

		public void witnessHasPushSizeLimit()
		{
			Key bob = new Key();
			Transaction tx = new Transaction();
			tx.Outputs.Add(new TxOut(Money.Coins(1.0m), bob.PubKey.ScriptPubKey.WitHash));
			WitScriptCoin coin = new WitScriptCoin(tx.Outputs.AsCoins().First(), bob.PubKey.ScriptPubKey);

			Transaction spending = new Transaction();
			spending.AddInput(tx, 0);
			spending.Sign(bob, coin);
			ScriptError error;
			Assert.True(spending.Inputs.AsIndexedInputs().First().VerifyScript(coin, out error));
			spending.Inputs[0].WitScript = new WitScript(new[] { new byte[521] }.Concat(spending.Inputs[0].WitScript.Pushes).ToArray());
			Assert.False(spending.Inputs.AsIndexedInputs().First().VerifyScript(coin, out error));
			Assert.Equal(ScriptError.PushSize, error);
		}
开发者ID:knocte,项目名称:NBitcoin,代码行数:16,代码来源:transaction_tests.cs

示例7: Transactions

 public void Transactions()
 {
     // This test covers a bug in which Transaction.getValueSentFromMe was calculating incorrectly.
     var tx = TestUtils.CreateFakeTx(_params, Utils.ToNanoCoins(1, 0), _myAddress);
     // Now add another output (ie, change) that goes to some other address.
     var someOtherGuy = new EcKey().ToAddress(_params);
     var output = new TransactionOutput(_params, tx, Utils.ToNanoCoins(0, 5), someOtherGuy);
     tx.AddOutput(output);
     // Note that tx is no longer valid: it spends more than it imports. However checking transactions balance
     // correctly isn't possible in SPV mode because value is a property of outputs not inputs. Without all
     // transactions you can't check they add up.
     _wallet.Receive(tx, null, BlockChain.NewBlockType.BestChain);
     // Now the other guy creates a transaction which spends that change.
     var tx2 = new Transaction(_params);
     tx2.AddInput(output);
     tx2.AddOutput(new TransactionOutput(_params, tx2, Utils.ToNanoCoins(0, 5), _myAddress));
     // tx2 doesn't send any coins from us, even though the output is in the wallet.
     Assert.AreEqual(Utils.ToNanoCoins(0, 0), tx2.GetValueSentFromMe(_wallet));
 }
开发者ID:Tsunami-ide,项目名称:Bitcoin,代码行数:19,代码来源:WalletTest.cs

示例8: Bounce

 public void Bounce()
 {
     // This test covers bug 64 (False double spends). Check that if we create a spend and it's immediately sent
     // back to us, this isn't considered as a double spend.
     var coin1 = Utils.ToNanoCoins(1, 0);
     var coinHalf = Utils.ToNanoCoins(0, 50);
     // Start by giving us 1 coin.
     var inbound1 = TestUtils.CreateFakeTx(_params, coin1, _myAddress);
     _wallet.Receive(inbound1, null, BlockChain.NewBlockType.BestChain);
     // Send half to some other guy. Sending only half then waiting for a confirm is important to ensure the tx is
     // in the unspent pool, not pending or spent.
     Assert.AreEqual(1, _wallet.GetPoolSize(Wallet.Pool.Unspent));
     Assert.AreEqual(1, _wallet.GetPoolSize(Wallet.Pool.All));
     var someOtherGuy = new EcKey().ToAddress(_params);
     var outbound1 = _wallet.CreateSend(someOtherGuy, coinHalf);
     _wallet.ConfirmSend(outbound1);
     _wallet.Receive(outbound1, null, BlockChain.NewBlockType.BestChain);
     // That other guy gives us the coins right back.
     var inbound2 = new Transaction(_params);
     inbound2.AddOutput(new TransactionOutput(_params, inbound2, coinHalf, _myAddress));
     inbound2.AddInput(outbound1.Outputs[0]);
     _wallet.Receive(inbound2, null, BlockChain.NewBlockType.BestChain);
     Assert.AreEqual(coin1, _wallet.GetBalance());
 }
开发者ID:Tsunami-ide,项目名称:Bitcoin,代码行数:24,代码来源:WalletTest.cs

示例9: CreateGenesis

        //public boolean equals(Object other) {
        //    if (!(other instanceof NetworkParameters)) return false;
        //    NetworkParameters o = (NetworkParameters) other;
        //    return o.getId().equals(getId());
        //}
        public Block CreateGenesis(NetworkParameters n)
        {
            Block genesisBlock=new Block(n);
            Transaction transaction=new Transaction(n);
            transaction.AddInput(
                new TransactionInput(n,transaction,Hex.Decode(n.GenesisBlockInputScriptSig))
            );

            ByteArrayOutputStream scriptPubKeyBytes = new ByteArrayOutputStream();
            Script.writeBytes(scriptPubKeyBytes,Hex.Decode(n.GenesisOutputScriptPubKey));
            scriptPubKeyBytes.write(Script.OP_CHECKSIG);
            t.addOutput(new TransactionOutput(n,transaction,Coin.FromCoins(50).Nanocoins,scriptPubKeyBytes.toByteArray()));

            genesisBlock.addTransaction(transaction);
            return genesisBlock;
        }
开发者ID:knocte,项目名称:BitcoinDotNet,代码行数:21,代码来源:ANetworkParameters.cs

示例10: addOnlyInputToTransaction

        private void addOnlyInputToTransaction(Transaction t, TransactionOutPointWithValue prevOut, uint sequence)
        {
            TxIn input = new TxIn(prevOut.outpoint)
            {
                ScriptSig = new Script(Op.GetPushOp(0))
            };
            input.Sequence = sequence;
            t.AddInput(input);

            var hash = prevOut.scriptPubKey.SignatureHash(t, 0, SigHash.All);
            input.ScriptSig = new PayToPubkeyHashTemplate().GenerateScriptSig(new TransactionSignature(coinbaseOutKey.Sign(hash), SigHash.All),coinbaseOutKeyPubKey);
        }
开发者ID:nikropht,项目名称:NBitcoin,代码行数:12,代码来源:FullBlockTestGenerator.cs


注:本文中的Transaction.AddInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。