Пример #1
0
        /// <summary>
        /// Extract P2SH or P2PH id from scriptPubKey
        /// </summary>
        /// <param name="network"></param>
        /// <returns></returns>
        public TxDestination GetDestination()
        {
            var pubKeyHashParams = _PayToPubkeyHash.ExtractScriptPubKeyParameters(this);

            if (pubKeyHashParams != null)
            {
                return(pubKeyHashParams);
            }
            var scriptHashParams = _PayToScriptHash.ExtractScriptPubKeyParameters(this);

            if (scriptHashParams != null)
            {
                return(scriptHashParams);
            }
            return(null);
        }
Пример #2
0
        private void ParseSpendable()
        {
            List <KeyId> pubkeys = new List <KeyId>();

            var payToHash = new PayToPubkeyHashTemplate();
            var keyId     = payToHash.ExtractScriptPubKeyParameters(SpendableScript);

            if (keyId != null)
            {
                StealthKeys = new StealthSpendKey[] { new StealthSpendKey(keyId, this) };
            }
            else
            {
                var payToMultiSig = new PayToMultiSigTemplate();
                var para          = payToMultiSig.ExtractScriptPubKeyParameters(SpendableScript);
                if (para == null)
                {
                    throw new ArgumentException("Invalid stealth spendable output script", "spendable");
                }
                StealthKeys = para.PubKeys.Select(k => new StealthSpendKey(k.ID, this)).ToArray();
            }
        }
Пример #3
0
        private void ParseSpendable()
        {
            List<KeyId> pubkeys = new List<KeyId>();

            var payToHash = new PayToPubkeyHashTemplate();
            var keyId = payToHash.ExtractScriptPubKeyParameters(SpendableScript);
            if(keyId != null)
            {
                StealthKeys = new StealthSpendKey[] { new StealthSpendKey(keyId, this) };
            }
            else
            {
                var payToMultiSig = new PayToMultiSigTemplate();
                var para = payToMultiSig.ExtractScriptPubKeyParameters(SpendableScript);
                if(para == null)
                    throw new ArgumentException("Invalid stealth spendable output script", "spendable");
                StealthKeys = para.PubKeys.Select(k => new StealthSpendKey(k.ID, this)).ToArray();
            }
        }