Skip to content

Commit

Permalink
External hook to extend TransactionBuilder.FindCoin
Browse files Browse the repository at this point in the history
  • Loading branch information
dthorpe committed Nov 18, 2014
1 parent d667ca3 commit f8a78a6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion NBitcoin/TransactionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ public ICoinSelector CoinSelector
set;
}

public Func<OutPoint, ICoin> CoinFinder { get; set; }

LockTime? _LockTime;
public TransactionBuilder SetLockTime(LockTime lockTime)
{
Expand Down Expand Up @@ -777,7 +779,12 @@ private Exception CoinNotFound(TxIn txIn)

private ICoin FindCoin(OutPoint outPoint)
{
return _BuilderGroups.SelectMany(c => c.Coins).FirstOrDefault(c => c.Outpoint == outPoint);
var result = _BuilderGroups.SelectMany(c => c.Coins).FirstOrDefault(c => c.Outpoint == outPoint);

if (result == null && CoinFinder != null)
result = CoinFinder(outPoint);

return result;
}

readonly static PayToScriptHashTemplate payToScriptHash = new PayToScriptHashTemplate();
Expand Down

0 comments on commit f8a78a6

Please sign in to comment.