private bool ChainGetTx() { if (stack.Count < 1) { return(false); } StackItem x = stack.Pop(); Transaction[] r = x.GetArray <UInt256>().Select(p => Blockchain.Default?.GetTransaction(p)).ToArray(); if (x.IsArray) { stack.Push(new StackItem(r)); } else { stack.Push(new StackItem(r[0])); } return(true); }
private bool BlockGetTx() { if (stack.Count < 1 || altStack.Count < 1) { return(false); } StackItem block_item = altStack.Peek(); Block[] blocks = block_item.GetArray <Block>(); if (blocks.Any(p => p == null || p.IsHeader)) { return(false); } StackItem index_item = stack.Pop(); BigInteger[] indexes = index_item.GetIntArray(); if (block_item.IsArray && index_item.IsArray && blocks.Length != indexes.Length) { return(false); } if (blocks.Length == 1) { blocks = Enumerable.Repeat(blocks[0], indexes.Length).ToArray(); } else if (indexes.Length == 1) { indexes = Enumerable.Repeat(indexes[0], blocks.Length).ToArray(); } Transaction[] tx = blocks.Zip(indexes, (b, i) => i >= b.Transactions.Length ? null : b.Transactions[(int)i]).ToArray(); if (block_item.IsArray || index_item.IsArray) { stack.Push(new StackItem(tx)); } else { stack.Push(new StackItem(tx[0])); } return(true); }
private bool BlockTxCount() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); Block[] blocks = x.GetArray <Block>(); if (blocks.Any(p => p == null || p.IsHeader)) { return(false); } int[] r = blocks.Select(p => p.Transactions.Length).ToArray(); if (x.IsArray) { stack.Push(r); } else { stack.Push(r[0]); } return(true); }
private bool HeaderNextMiner(ScriptEngine engine) { if (engine.AltStack.Count < 1) { return(false); } StackItem x = engine.AltStack.Peek(); BlockBase[] headers = x.GetArray <BlockBase>(); if (headers.Any(p => p == null)) { return(false); } UInt160[] r = headers.Select(p => p.NextMiner).ToArray(); if (x.IsArray) { engine.Stack.Push(new StackItem(r)); } else { engine.Stack.Push(new StackItem(r[0])); } return(true); }
private bool TxOutValue() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); TransactionOutput[] outputs = x.GetArray <TransactionOutput>(); if (outputs.Any(p => p == null)) { return(false); } long[] r = outputs.Select(p => p.Value.GetData()).ToArray(); if (x.IsArray) { stack.Push(r); } else { stack.Push(r[0]); } return(true); }
private bool TxInHash() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); TransactionInput[] inputs = x.GetArray <TransactionInput>(); if (inputs.Any(p => p == null)) { return(false); } UInt256[] r = inputs.Select(p => p.PrevHash).ToArray(); if (x.IsArray) { stack.Push(new StackItem(r)); } else { stack.Push(new StackItem(r[0])); } return(true); }
private bool EnrollPubkey() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); EnrollmentTransaction[] tx = x.GetArray <EnrollmentTransaction>(); if (tx.Any(p => p == null)) { return(false); } ECPoint[] r = tx.Select(p => p.PublicKey).ToArray(); if (x.IsArray) { stack.Push(new StackItem(r)); } else { stack.Push(new StackItem(r[0])); } return(true); }
private bool AssetAmount() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); RegisterTransaction[] tx = x.GetArray <RegisterTransaction>(); if (tx.Any(p => p == null)) { return(false); } long[] r = tx.Select(p => p.Amount.GetData()).ToArray(); if (x.IsArray) { stack.Push(r); } else { stack.Push(r[0]); } return(true); }
private bool AssetIssuer(ScriptEngine engine) { if (engine.AltStack.Count < 1) { return(false); } StackItem x = engine.AltStack.Peek(); RegisterTransaction[] tx = x.GetArray <RegisterTransaction>(); if (tx.Any(p => p == null)) { return(false); } ECPoint[] r = tx.Select(p => p.Issuer).ToArray(); if (x.IsArray) { engine.Stack.Push(new StackItem(r)); } else { engine.Stack.Push(new StackItem(r[0])); } return(true); }
private bool TxType(ScriptEngine engine) { if (engine.AltStack.Count < 1) { return(false); } StackItem x = engine.AltStack.Peek(); Transaction[] tx = x.GetArray <Transaction>(); if (tx.Any(p => p == null)) { return(false); } byte[][] r = tx.Select(p => new[] { (byte)p.Type }).ToArray(); if (x.IsArray) { engine.Stack.Push(r); } else { engine.Stack.Push(r[0]); } return(true); }
private bool BlockTxCount(ScriptEngine engine) { if (engine.AltStack.Count < 1) { return(false); } StackItem x = engine.AltStack.Peek(); Block[] blocks = x.GetArray <Block>(); if (blocks.Any(p => p == null)) { return(false); } int[] r = blocks.Select(p => p.Transactions.Length).ToArray(); if (x.IsArray) { engine.Stack.Push(r); } else { engine.Stack.Push(r[0]); } return(true); }
private bool HeaderTimestamp(ScriptEngine engine) { if (engine.AltStack.Count < 1) { return(false); } StackItem x = engine.AltStack.Peek(); Block[] headers = x.GetArray <Block>(); if (headers.Any(p => p == null)) { return(false); } uint[] r = headers.Select(p => p.Timestamp).ToArray(); if (x.IsArray) { engine.Stack.Push(r); } else { engine.Stack.Push(r[0]); } return(true); }
private bool HeaderMerkleRoot(ScriptEngine engine) { if (engine.AltStack.Count < 1) { return(false); } StackItem x = engine.AltStack.Peek(); Block[] headers = x.GetArray <Block>(); if (headers.Any(p => p == null)) { return(false); } UInt256[] r = headers.Select(p => p.MerkleRoot).ToArray(); if (x.IsArray) { engine.Stack.Push(new StackItem(r)); } else { engine.Stack.Push(new StackItem(r[0])); } return(true); }
private bool HeaderVersion() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); Block[] headers = x.GetArray <Block>(); if (headers.Any(p => p == null)) { return(false); } uint[] r = headers.Select(p => Block.Version).ToArray(); //header.Version if (x.IsArray) { stack.Push(r); } else { stack.Push(r[0]); } return(true); }
private bool TxHash() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); Transaction[] tx = x.GetArray <Transaction>(); if (tx.Any(p => p == null)) { return(false); } UInt256[] r = tx.Select(p => p.Hash).ToArray(); if (x.IsArray) { stack.Push(new StackItem(r)); } else { stack.Push(new StackItem(r[0])); } return(true); }
private bool AssetType() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); RegisterTransaction[] tx = x.GetArray <RegisterTransaction>(); if (tx.Any(p => p == null)) { return(false); } byte[][] r = tx.Select(p => new[] { (byte)p.AssetType }).ToArray(); if (x.IsArray) { stack.Push(r); } else { stack.Push(r[0]); } return(true); }
private bool AttrUsage(ScriptEngine engine) { if (engine.AltStack.Count < 1) { return(false); } StackItem x = engine.AltStack.Peek(); TransactionAttribute[] attr = x.GetArray <TransactionAttribute>(); if (attr.Any(p => p == null)) { return(false); } byte[][] r = attr.Select(p => new[] { (byte)p.Usage }).ToArray(); if (x.IsArray) { engine.Stack.Push(r); } else { engine.Stack.Push(r[0]); } return(true); }
private bool AssetAdmin() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); RegisterTransaction[] tx = x.GetArray <RegisterTransaction>(); if (tx.Any(p => p == null)) { return(false); } UInt160[] r = tx.Select(p => p.Admin).ToArray(); if (x.IsArray) { stack.Push(new StackItem(r)); } else { stack.Push(new StackItem(r[0])); } return(true); }
private bool TxOutAsset(ScriptEngine engine) { if (engine.AltStack.Count < 1) { return(false); } StackItem x = engine.AltStack.Peek(); TransactionOutput[] outputs = x.GetArray <TransactionOutput>(); if (outputs.Any(p => p == null)) { return(false); } UInt256[] r = outputs.Select(p => p.AssetId).ToArray(); if (x.IsArray) { engine.Stack.Push(new StackItem(r)); } else { engine.Stack.Push(new StackItem(r[0])); } return(true); }
private bool AttrData() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); TransactionAttribute[] attr = x.GetArray <TransactionAttribute>(); if (attr.Any(p => p == null)) { return(false); } byte[][] r = attr.Select(p => p.Data).ToArray(); if (x.IsArray) { stack.Push(r); } else { stack.Push(r[0]); } return(true); }
private bool HeaderNonce() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); Block[] headers = x.GetArray <Block>(); if (headers.Any(p => p == null)) { return(false); } ulong[] r = headers.Select(p => p.Nonce).ToArray(); if (x.IsArray) { stack.Push(r); } else { stack.Push(r[0]); } return(true); }
private bool TxInIndex() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); TransactionInput[] inputs = x.GetArray <TransactionInput>(); if (inputs.Any(p => p == null)) { return(false); } uint[] r = inputs.Select(p => (uint)p.PrevIndex).ToArray(); if (x.IsArray) { stack.Push(r); } else { stack.Push(r[0]); } return(true); }
private bool HeaderNextMiner() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); Block[] headers = x.GetArray <Block>(); if (headers.Any(p => p == null)) { return(false); } UInt160[] r = headers.Select(p => p.NextMiner).ToArray(); if (x.IsArray) { stack.Push(new StackItem(r)); } else { stack.Push(new StackItem(r[0])); } return(true); }
private bool TxOutScriptHash() { if (altStack.Count < 1) { return(false); } StackItem x = altStack.Peek(); TransactionOutput[] outputs = x.GetArray <TransactionOutput>(); if (outputs.Any(p => p == null)) { return(false); } UInt160[] r = outputs.Select(p => p.ScriptHash).ToArray(); if (x.IsArray) { stack.Push(new StackItem(r)); } else { stack.Push(new StackItem(r[0])); } return(true); }
private bool HeaderNonce(ScriptEngine engine) { if (engine.AltStack.Count < 1) { return(false); } StackItem x = engine.AltStack.Peek(); BlockBase[] headers = x.GetArray <BlockBase>(); if (headers.Any(p => p == null)) { return(false); } ulong[] r = headers.Select(p => p.Nonce).ToArray(); if (x.IsArray) { engine.Stack.Push(r); } else { engine.Stack.Push(r[0]); } return(true); }