Commit 13033521 authored by Sergei Zubov's avatar Sergei Zubov

Merge transaction builder

parent f975861a
......@@ -17,13 +17,16 @@ namespace NBitcoin
this.CoinSelector = new DeStreamCoinSelector(seed);
}
protected override IEnumerable<ICoin> BuildTransaction(TransactionBuildingContext ctx, BuilderGroup group,
protected override IEnumerable<ICoin> BuildTransaction(
TransactionBuildingContext ctx,
BuilderGroup group,
IEnumerable<Func<TransactionBuildingContext, IMoney>> builders,
IEnumerable<ICoin> coins, IMoney zero)
IEnumerable<ICoin> coins,
IMoney zero)
{
IEnumerable<ICoin> result = base.BuildTransaction(ctx, group, builders, coins, zero);
if (ctx.Transaction.Inputs.Any(p => p.PrevOut.Hash == uint256.Zero))
if (ctx.Transaction.Inputs.GetChangePointers().Any())
return result;
// To secure that fee is charged from spending coins and not from change,
......
......@@ -46,7 +46,7 @@ namespace NBitcoin
}
private Random _Rand = new Random();
protected Random _Rand = new Random();
public DefaultCoinSelector(int seed)
{
this._Rand = new Random(seed);
......@@ -62,7 +62,7 @@ namespace NBitcoin
#region ICoinSelector Members
public IEnumerable<ICoin> Select(IEnumerable<ICoin> coins, IMoney target)
public virtual IEnumerable<ICoin> Select(IEnumerable<ICoin> coins, IMoney target)
{
IMoney zero = target.Sub(target);
......@@ -330,7 +330,7 @@ namespace NBitcoin
}
}
internal class TransactionBuildingContext
protected internal class TransactionBuildingContext
{
public TransactionBuildingContext(TransactionBuilder builder)
{
......@@ -472,7 +472,7 @@ namespace NBitcoin
}
}
internal class BuilderGroup
protected internal class BuilderGroup
{
private TransactionBuilder _Parent;
public BuilderGroup(TransactionBuilder parent)
......@@ -1164,7 +1164,7 @@ namespace NBitcoin
return c.Amount >= this.FilterUneconomicalCoinsRate.GetFee(vSize);
}
private IEnumerable<ICoin> BuildTransaction(
protected virtual IEnumerable<ICoin> BuildTransaction(
TransactionBuildingContext ctx,
BuilderGroup group,
IEnumerable<Builder> builders,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment