private void CheckSignatures() { if (context.Signatures.Count(p => p != null) >= context.M && context.TransactionHashes.All(p => context.Transactions.ContainsKey(p))) { Log($"{nameof(CheckSignatures)} {context.Signatures.Count(p => p != null)}/{context.M}"); Contract contract = Contract.CreateMultiSigContract(context.Miners[context.MinerIndex].EncodePoint(true).ToScriptHash(), context.M, context.Miners); Block block = context.MakeHeader(); SignatureContext sc = new SignatureContext(block); for (int i = 0; i < context.Miners.Length; i++) { if (context.Signatures[i] != null) { sc.Add(contract, context.Miners[i], context.Signatures[i]); } } sc.Signable.Scripts = sc.GetScripts(); block.Transactions = context.TransactionHashes.Select(p => context.Transactions[p]).ToArray(); Log($"RelayBlock hash:{block.Hash}"); if (!LocalNode.Relay(block)) { Log($"failed hash:{block.Hash}"); } context.State |= ConsensusState.BlockSent; } }
private void button3_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex < 0) { return; } if (listBox2.SelectedIndex < 0) { return; } byte[] parameter; ContractParameterType type = (ContractParameterType)listBox2.SelectedItem; switch (type) { case ContractParameterType.Integer: parameter = BigInteger.Parse(textBox2.Text).ToByteArray(); break; case ContractParameterType.Hash160: parameter = UInt160.Parse(textBox2.Text).ToArray(); break; case ContractParameterType.Hash256: parameter = UInt256.Parse(textBox2.Text).ToArray(); break; default: parameter = textBox2.Text.HexToBytes(); break; } Contract contract = Program.CurrentWallet.GetContract(Wallet.ToScriptHash((string)listBox1.SelectedItem)); if (!context.Add(contract, listBox2.SelectedIndex, parameter)) { throw new InvalidOperationException(); } textBox1.Text = textBox2.Text; button4.Visible = context.Completed; }