public List <string> GetPrivateKeys(string password, List <Coin> spentCoins) { var wallet = WalletDao.GetWalletById(CurrentWallet.Id); if (MD5Helper.ToMD5(password) != wallet.Password) { throw new WTException(ExceptionCode.WrongWalletPassword, "密码错误"); } var network = NetworkOperator.Instance.Network; var addresses = spentCoins.Select(o => o.ScriptPubKey.GetDestinationAddress(network).ToString()).Distinct().ToList(); var addressInfos = AddressDao.GetByAddresses(CurrentWallet.Id, addresses); if (addressInfos.Count == 0 || addressInfos.Count != addresses.Count) { throw new WTException(ExceptionCode.AddressNotExisted, "当前钱包找不到相关比特币地址"); } var privateKeys = new List <string>(); foreach (var addr in addressInfos) { var keyPath = new KeyPath(addr.KeyPath); var rootXPrivKey = ExtKey.Parse(CurrentWallet.RootXPrivKey, network); var xPrivKey = rootXPrivKey.Derive(keyPath); var privKeyWif = xPrivKey.PrivateKey.GetWif(network).ToString(); privateKeys.Add(privKeyWif); } return(privateKeys); }