public MultisigAddressHelper(Network targetChainNetwork, Network sourceChainNetwork, int quorum = 2, int sigCount = 3)
            : base(targetChainNetwork, sourceChainNetwork)
        {
            // TODO: This still needs some work.

            this.MultisigMnemonics = Enumerable.Range(0, sigCount)
                                     .Select(i => new Mnemonic(Wordlist.English, WordCount.Twelve))
                                     .ToArray();

            this.MultisigPrivateKeys = this.MultisigMnemonics
                                       .Select(m => m.DeriveExtKey(Passphrase).PrivateKey)
                                       .ToArray();

            FederationId federationId = targetChainNetwork.Federations.GetOnlyFederation().Id;

            this.PayToMultiSig = targetChainNetwork.Federations.GetOnlyFederation().MultisigScript;
            //PayToMultiSigTemplate.Instance.GenerateScriptPubKey(
            //quorum, this.MultisigPrivateKeys.Select(k => k.PubKey).ToArray());

            this.SourceChainMultisigAddress = this.PayToMultiSig.Hash.GetAddress(this.SourceChainNetwork);
            this.SourceChainPayToScriptHash = this.SourceChainMultisigAddress.ScriptPubKey;

            this.TargetChainMultisigAddress = this.PayToMultiSig.Hash.GetAddress(this.TargetChainNetwork);
            this.TargetChainPayToScriptHash = this.TargetChainMultisigAddress.ScriptPubKey;
        }
Exemplo n.º 2
0
        public Script GenerateScriptPubKey(FederationId federationId)
        {
            var ops = new List <Op>();

            ops.Add(Op.GetPushOp(federationId.ToBytes()));
            ops.Add(OpcodeType.OP_NOP9); // OP_FEDERATION
            ops.Add(OpcodeType.OP_CHECKMULTISIG);
            return(new Script(ops));
        }
        public static FederatedPegSettings CreateSettings(Network network, Network counterChainNetwork, out NodeSettings nodeSettings)
        {
            FederationId federationId   = network.Federations.GetOnlyFederation().Id;
            string       redeemScript   = PayToFederationTemplate.Instance.GenerateScriptPubKey(federationId).ToString();
            string       federationIps  = "127.0.0.1:36201,127.0.0.1:36202,127.0.0.1:36203";
            string       multisigPubKey = network.Federations.GetFederation(federationId).GetFederationDetails().pubKeys.TakeLast(1).First().ToHex();

            string[] args = new[] { "-sidechain", "-regtest", $"-federationips={federationIps}", $"-redeemscript={redeemScript}", $"-publickey={multisigPubKey}", "-mincoinmaturity=1", "-mindepositconfirmations=1" };
            nodeSettings = new NodeSettings(network, ProtocolVersion.ALT_PROTOCOL_VERSION, args: args);

            var settings = new FederatedPegSettings(nodeSettings, new CounterChainNetworkWrapper(counterChainNetwork));

            return(settings);
        }
Exemplo n.º 4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (FederationId.Length != 0)
            {
                hash ^= FederationId.GetHashCode();
            }
            if (NameId.Length != 0)
            {
                hash ^= NameId.GetHashCode();
            }
            hash ^= Attributes.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }