From 8985184efc6b6598dc61a8e1e73480c2a6381bf8 Mon Sep 17 00:00:00 2001 From: Shargon Date: Thu, 30 Jan 2020 18:31:51 +0100 Subject: [PATCH] Allow to get the current tx --- .../InteropService.Blockchain.cs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/neo/SmartContract/InteropService.Blockchain.cs b/src/neo/SmartContract/InteropService.Blockchain.cs index b31aba4a32..60e6e1906d 100644 --- a/src/neo/SmartContract/InteropService.Blockchain.cs +++ b/src/neo/SmartContract/InteropService.Blockchain.cs @@ -45,8 +45,25 @@ private static bool Blockchain_GetBlock(ApplicationEngine engine) private static bool Blockchain_GetTransaction(ApplicationEngine engine) { - ReadOnlySpan 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