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 = MultiSigContract.Create(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; } }
public MultiSigContract GetContract() { ECPoint[] publicKeys = listBox1.Items.OfType <string>().Select(p => ECPoint.DecodePoint(p.HexToBytes(), ECCurve.Secp256r1)).ToArray(); foreach (ECPoint publicKey in publicKeys) { Account account = Program.CurrentWallet.GetAccount(publicKey.EncodePoint(true).ToScriptHash()); if (account != null) { return(MultiSigContract.Create(account.PublicKeyHash, (int)numericUpDown2.Value, publicKeys)); } } return(null); }