コード例 #1
0
ファイル: Wallet.cs プロジェクト: SpotLabsNET/BitcoinTool
        public static Wallet FromWIF(string privateKey, Action <bool> isCompressed = null)
        {
            CheckBase58(privateKey);

            byte[] privateKeyBytes;
            switch (privateKey.Length)
            {
            case 51:
            case 52:
                ValidatePrivateKey(privateKey);
                privateKeyBytes = Encoders.WIFToBytes(privateKey);
                break;

            default:
                throw new System.ArgumentException("Key must be 51 or 52 chars");
            }

            var compressed = privateKey.Length == 52;

            if (isCompressed != null)
            {
                isCompressed(compressed);
            }

            return(new Wallet(privateKeyBytes));
        }