Skip to content

Commit

Permalink
Allow to get the current tx
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon committed Jan 30, 2020
1 parent 6521582 commit 8985184
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/neo/SmartContract/InteropService.Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,25 @@ private static bool Blockchain_GetBlock(ApplicationEngine engine)

private static bool Blockchain_GetTransaction(ApplicationEngine engine)
{
ReadOnlySpan<byte> hash = engine.CurrentContext.EvaluationStack.Pop().GetSpan();
Transaction tx = engine.Snapshot.GetTransaction(new UInt256(hash));
Transaction tx;
StackItem item = engine.CurrentContext.EvaluationStack.Pop();

if (item.IsNull)
{
if (engine.ScriptContainer is Transaction senderTx)
{
tx = senderTx;
}
else
{
return false;
}
}
else
{
tx = engine.Snapshot.GetTransaction(new UInt256(item.GetSpan()));
}

if (tx == null)
engine.CurrentContext.EvaluationStack.Push(StackItem.Null);
else
Expand Down

0 comments on commit 8985184

Please sign in to comment.