Skip to content

Commit

Permalink
renaming in ScriptEvaluation, BlockrTransactionRepository support tes…
Browse files Browse the repository at this point in the history
…tnet
  • Loading branch information
NicolasDorier committed Oct 19, 2014
1 parent 5b69064 commit 01cf148
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 13 additions & 2 deletions NBitcoin/BlockrTransactionRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,21 @@ public string Status
public class BlockrTransactionRepository : ITransactionRepository
{
public BlockrTransactionRepository()
: this(null)
{

}
public BlockrTransactionRepository(Network network)
{
if(network == null)
Network = Network.Main;
}

public Network Network
{
get;
set;
}


#region ITransactionRepository Members
Expand All @@ -46,7 +57,7 @@ public Transaction Get(uint256 txId)
while(true)
{
WebClient client = new WebClient();
var result = client.DownloadString("http://btc.blockr.io/api/v1/tx/raw/" + txId);
var result = client.DownloadString("http://" + (Network == Network.Main ? "" : "t") + "btc.blockr.io/api/v1/tx/raw/" + txId);
var json = JObject.Parse(result);
var status = json["status"];
var code = json["code"];
Expand All @@ -61,7 +72,7 @@ public Transaction Get(uint256 txId)

public void Put(uint256 txId, Transaction tx)
{

}

#endregion
Expand Down
5 changes: 2 additions & 3 deletions NBitcoin/ScriptEvaluationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ public bool VerifyScript(Script scriptSig, Script scriptPubKey, Transaction txTo
if(evaluationCopy.Stack.Count == 0)
throw new InvalidProgramException("stackCopy cannot be empty here");

var pubKeySerialized = evaluationCopy.Stack.Pop();
Script pubKey2 = new Script(pubKeySerialized);
Script redeem = new Script(evaluationCopy.Stack.Pop());

if(!evaluationCopy.EvalScript(pubKey2, txTo, nIn))
if(!evaluationCopy.EvalScript(redeem, txTo, nIn))
return false;

return evaluationCopy.Result != null && evaluationCopy.Result.Value;
Expand Down

0 comments on commit 01cf148

Please sign in to comment.