本文整理汇总了C#中Transaction.GetValueSentFromMe方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.GetValueSentFromMe方法的具体用法?C# Transaction.GetValueSentFromMe怎么用?C# Transaction.GetValueSentFromMe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction.GetValueSentFromMe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBalances
public void TestBalances()
{
var nanos = Utils.ToNanoCoins(1, 0);
var tx1 = CreateFakeTx(nanos, _myAddress);
_wallet.Receive(tx1, null, BlockChain.NewBlockType.BestChain);
Assert.AreEqual(nanos, tx1.GetValueSentToMe(_wallet, true));
// Send 0.10 to somebody else.
var send1 = _wallet.CreateSend(new EcKey().ToAddress(_params), Utils.ToNanoCoins(0, 10), _myAddress);
// Re-serialize.
var send2 = new Transaction(_params, send1.BitcoinSerialize());
Assert.AreEqual(nanos, send2.GetValueSentFromMe(_wallet));
}
示例2: 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));
}