Ejemplo n.º 1
0
        public UnspentOutput(Blake256Hash txHash, uint outputIndex, byte tree, Amount amount, OutputScript pkScript, DateTimeOffset seenTime, bool isFromCoinbase)
        {
            if (txHash == null)
                throw new ArgumentNullException(nameof(txHash));
            if (pkScript == null)
                throw new ArgumentNullException(nameof(pkScript));

            TransactionHash = txHash;
            OutputIndex = outputIndex;
            Tree = tree;
            Amount = amount;
            PkScript = pkScript;
            SeenTime = seenTime;
            IsFromCoinbase = IsFromCoinbase;
        }
Ejemplo n.º 2
0
        public static bool TryFromOutputScript(OutputScript pkScript, BlockChainIdentity intendedBlockChain, out Address address)
        {
            var payToPubKeyHashScript = pkScript as OutputScript.Secp256k1PubKeyHash;
            if (payToPubKeyHashScript != null)
            {
                address = new PayToSecp256k1PubKeyHash(intendedBlockChain, payToPubKeyHashScript.Hash160);
                return true;
            }

            var payToEd25519PubKeyHashScript = pkScript as OutputScript.Ed25519PubKeyHash;
            if (payToEd25519PubKeyHashScript != null)
            {
                address = new PayToEd25519PubKeyHash(intendedBlockChain, payToEd25519PubKeyHashScript.Hash160);
                return true;
            }

            var payToSecSchnorrPubKeyHash = pkScript as OutputScript.SecSchnorrPubKeyHash;
            if (payToSecSchnorrPubKeyHash != null)
            {
                address = new PayToSecSchnorrPubKeyHash(intendedBlockChain, payToSecSchnorrPubKeyHash.Hash160);
                return true;
            }

            var payToScriptHashScript = pkScript as OutputScript.ScriptHash;
            if (payToScriptHashScript != null)
            {
                address = new PayToScriptHash(intendedBlockChain, payToScriptHashScript.Hash160);
                return true;
            }

            address = null;
            return false;
        }