コード例 #1
0
ファイル: OfflineNode.cs プロジェクト: d3minem/neo-express
        public Task <RpcInvokeResult> InvokeAsync(Neo.VM.Script script)
        {
            try
            {
                if (disposedValue)
                {
                    return(Task.FromException <RpcInvokeResult>(new ObjectDisposedException(nameof(OfflineNode))));
                }

                using ApplicationEngine engine = script.Invoke(neoSystem.Settings, neoSystem.StoreView);
                return(Task.FromResult(new RpcInvokeResult()
                {
                    State = engine.State,
                    Exception = engine.FaultException?.GetBaseException().Message ?? string.Empty,
                    GasConsumed = engine.GasConsumed,
                    Stack = engine.ResultStack.ToArray(),
                    Script = string.Empty,
                    Tx = string.Empty
                }));
            }
            catch (Exception ex)
            {
                return(Task.FromException <RpcInvokeResult>(ex));
            }
        }
コード例 #2
0
 public static ApplicationEngine Invoke(this Neo.VM.Script script, ProtocolSettings settings, DataCache snapshot) => ApplicationEngine.Run(
     script: script,
     snapshot: snapshot,
     settings: settings);
コード例 #3
0
ファイル: Extensions.cs プロジェクト: neo-project/neo-express
 public static ApplicationEngine Invoke(this Neo.VM.Script script, ProtocolSettings settings, DataCache snapshot, IVerifiable?container = null)
 => ApplicationEngine.Run(
     script: script,
     snapshot: snapshot,
     settings: settings,
     container: container);
コード例 #4
0
ファイル: OfflineNode.cs プロジェクト: d3minem/neo-express
        public async Task <UInt256> ExecuteAsync(Wallet wallet, UInt160 accountHash, WitnessScope witnessScope, Neo.VM.Script script, decimal additionalGas = 0)
        {
            if (disposedValue)
            {
                throw new ObjectDisposedException(nameof(OfflineNode));
            }

            var signer = new Signer()
            {
                Account = accountHash, Scopes = witnessScope
            };
            var tx = wallet.MakeTransaction(neoSystem.StoreView, script, accountHash, new[] { signer });

            if (additionalGas > 0.0m)
            {
                tx.SystemFee += (long)additionalGas.ToBigInteger(NativeContract.GAS.Decimals);
            }

            var context = new ContractParametersContext(neoSystem.StoreView, tx, ProtocolSettings.Network);
            var account = wallet.GetAccount(accountHash) ?? throw new Exception();

            if (account.IsMultiSigContract())
            {
                var multiSigWallets = chain.GetMultiSigWallets(neoSystem.Settings, accountHash);
                for (int i = 0; i < multiSigWallets.Count; i++)
                {
                    multiSigWallets[i].Sign(context);
                    if (context.Completed)
                    {
                        break;
                    }
                }
            }
            else
            {
                wallet.Sign(context);
            }

            if (!context.Completed)
            {
                throw new Exception();
            }

            tx.Witnesses = context.GetWitnesses();
            return(await SubmitTransactionAsync(tx).ConfigureAwait(false));
        }