Пример #1
0
        public HDKeyData GetKey(int n)
        {
            var network = ExtPubKeys.Select(e => e.Network).FirstOrDefault();
            var root    = Path ?? new KeyPath();
            var next    = root.Derive(n, false);

            var keyData = new HDKeyData();

            keyData.ExtPubKeys = ExtPubKeys
                                 .Select(k => k.ExtPubKey.Derive(next).GetWif(network)).ToArray();
            keyData.Path         = next;
            keyData.RedeemScript = CreateScriptPubKey(keyData.ExtPubKeys);
            if (!P2SH)
            {
                keyData.ScriptPubKey = keyData.RedeemScript;
                keyData.RedeemScript = null;
                keyData.Address      = keyData.ScriptPubKey.GetDestinationAddress(network);
            }
            else
            {
                keyData.ScriptPubKey = keyData.RedeemScript.Hash.ScriptPubKey;
                keyData.Address      = keyData.ScriptPubKey.GetDestinationAddress(network);
            }
            return(keyData);
        }
Пример #2
0
        protected override async Task CreateTask(System.Threading.CancellationToken cancelation)
        {
            HDKeySet keyset = new HDKeySet();

            keyset.Name           = Name;
            keyset.Path           = String.IsNullOrWhiteSpace(KeyPath) ? null : new KeyPath(KeyPath);
            keyset.SignatureCount = SignatureCount;
            keyset.ExtPubKeys
                =
                    ExtPubKeys
                    .Select(_ => new BitcoinExtPubKey(_.Value, _Network))
                    .ToArray();

            var client = _Parent._Parent.ClientFactory.CreateClient();
            await client.CreateKeySet(_Parent.Name, keyset);

            Info("Keyset created");
            _Parent.Refresh.Execute(false);
        }