本文整理汇总了C#中Transaction.GetFee方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.GetFee方法的具体用法?C# Transaction.GetFee怎么用?C# Transaction.GetFee使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction.GetFee方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildContent
protected string BuildContent(Transaction tx)
{
return String.Format("transaction_subject=918562a4aa6348ba9f2fd69cfa6563c5\npayment_date=15%3A07%3A06+Mar+24%2C+2010+PDT\n" +
"txn_type=web_accept\nlast_name=User\nresidence_country=GB\nitem_name=Climatic+Data+for+ALC\n" +
"payment_gross=\nmc_currency={0}\nbusiness={1}\n" +
"payment_type=instant\nprotection_eligibility=Ineligible\npayer_status=verified\ntax=0.00\n" +
"payer_email=buyer2_1269459106_per%40triggerfishsoftware.co.uk\ntxn_id={2}\n" +
"quantity=1\nreceiver_email=grid_1269419750_biz%40triggerfishsoftware.co.uk\nfirst_name=Test\n" +
"payer_id=EA2FG2FSBQMUN\nreceiver_id=A79SPMGDKFXME\nitem_number={3}\nhandling_amount=0.00\n" +
"payment_status={4}\npayment_fee=\nmc_fee={5}\nshipping=0.00\nmc_gross={6}\n" +
"custom={7}\ncharset=windows-1252\n",
HttpUtility.UrlEncodeUnicode(tx.Currency),
HttpUtility.UrlEncodeUnicode(tx.Account),
HttpUtility.UrlEncodeUnicode(tx.Tx),
HttpUtility.UrlEncodeUnicode(tx.ItemNumber),
tx.State,
tx.GetFee().ToString(),
HttpUtility.UrlEncodeUnicode(tx.Amount),
HttpUtility.UrlEncodeUnicode(tx.Custom));
}
示例2: Check
public TransactionPolicyError[] Check(Transaction transaction, ICoin[] spentCoins)
{
spentCoins = spentCoins ?? new ICoin[0];
List<TransactionPolicyError> errors = new List<TransactionPolicyError>();
if(transaction.Version > Transaction.CURRENT_VERSION || transaction.Version < 1)
{
errors.Add(new TransactionPolicyError("Invalid transaction version, expected " + Transaction.CURRENT_VERSION));
}
var dups = transaction.Inputs.AsIndexedInputs().GroupBy(i => i.PrevOut);
foreach(var dup in dups)
{
var duplicates = dup.ToArray();
if(duplicates.Length != 1)
errors.Add(new DuplicateInputPolicyError(duplicates));
}
foreach(var input in transaction.Inputs.AsIndexedInputs())
{
var coin = spentCoins.FirstOrDefault(s => s.Outpoint == input.PrevOut);
if(coin == null)
{
errors.Add(new CoinNotFoundPolicyError(input));
}
}
var fees = transaction.GetFee(spentCoins);
if(fees != null)
{
if(fees < Money.Zero)
errors.Add(new NotEnoughFundsPolicyError("Not enough funds in this transaction", -fees));
}
return errors.ToArray();
}
示例3: Check
public TransactionPolicyError[] Check(Transaction transaction, ICoin[] spentCoins)
{
if(transaction == null)
throw new ArgumentNullException("transaction");
spentCoins = spentCoins ?? new ICoin[0];
List<TransactionPolicyError> errors = new List<TransactionPolicyError>();
foreach(var input in transaction.Inputs.AsIndexedInputs())
{
var coin = spentCoins.FirstOrDefault(s => s.Outpoint == input.PrevOut);
if(coin != null)
{
if(ScriptVerify != null)
{
ScriptError error;
if(!VerifyScript(input, coin.TxOut.ScriptPubKey, ScriptVerify.Value, out error))
{
errors.Add(new ScriptPolicyError(input, error, ScriptVerify.Value, coin.TxOut.ScriptPubKey));
}
}
}
var txin = input.TxIn;
if(txin.ScriptSig.Length > MaxScriptSigLength)
{
errors.Add(new InputPolicyError("Max scriptSig length exceeded actual is " + txin.ScriptSig.Length + ", max is " + MaxScriptSigLength, input));
}
if(!txin.ScriptSig.IsPushOnly)
{
errors.Add(new InputPolicyError("All operation should be push", input));
}
if(!txin.ScriptSig.HasCanonicalPushes)
{
errors.Add(new InputPolicyError("All operation should be canonical push", input));
}
}
foreach(var txout in transaction.Outputs.AsCoins())
{
var template = StandardScripts.GetTemplateFromScriptPubKey(txout.ScriptPubKey);
if(template == null)
errors.Add(new OutputPolicyError("Non-Standard scriptPubKey", (int)txout.Outpoint.N));
}
int txSize = transaction.GetSerializedSize();
if(MaxTransactionSize != null)
{
if(txSize >= MaxTransactionSize.Value)
errors.Add(new TransactionSizePolicyError(txSize, MaxTransactionSize.Value));
}
var fees = transaction.GetFee(spentCoins);
if(fees != null)
{
if(CheckFee)
{
if(MaxTxFee != null)
{
var max = MaxTxFee.GetFee(txSize);
if(fees > max)
errors.Add(new FeeTooHighPolicyError(fees, max));
}
if(MinRelayTxFee != null)
{
if(MinRelayTxFee != null)
{
var min = MinRelayTxFee.GetFee(txSize);
if(fees < min)
errors.Add(new FeeTooLowPolicyError(fees, min));
}
}
}
}
if(MinRelayTxFee != null)
{
foreach(var output in transaction.Outputs)
{
var bytes = output.ScriptPubKey.ToBytes(true);
if(output.IsDust(MinRelayTxFee) && !IsOpReturn(bytes))
errors.Add(new DustPolicyError(output.Value, output.GetDustThreshold(MinRelayTxFee)));
}
}
var opReturnCount = transaction.Outputs.Select(o => o.ScriptPubKey.ToBytes(true)).Count(b => IsOpReturn(b));
if(opReturnCount > 1)
errors.Add(new TransactionPolicyError("More than one op return detected"));
return errors.ToArray();
}