从 GetAddress 获取地址时出错 - Trezor Development

Error Getting Address from GetAddress - Trezor Development

我正在为 Trezor 构建一个 C# HID 库。它运作良好。我能够通过 pin 条目并检索我的 xpub,并且我可以获得地址。但是,none 返回的地址与我在 Trezor 钱包网站中的任何地址匹配。

您可以在此处查看 HID doco: https://doc.satoshilabs.com/trezor-tech/api-workflows.html#passphrase-meta-workflow

这不是真正的 C# 问题。相反,这是任何 Trezor HID 开发人员的普遍问题。最大的问题是,如果我将 HDNodePathType 消息作为 GetAddress 方法的多重签名 属性 传递,我会收到错误 "Can't encode address'"。 我需要通过 GetAddress 消息传递什么才能获得有效地址?

这是一个 Android 回购: https://github.com/trezor/trezor-android

此问题现已解决。 Trezor.Net 有一个可以克隆的工作示例 here

这是获取地址的code

public async Task<string> GetAddressAsync(IAddressPath addressPath, bool isPublicKey, bool display, AddressType addressType, InputScriptType inputScriptType, string coinName)
{
    try
    {
        var path = addressPath.ToArray();

        if (isPublicKey)
        {
            var publicKey = await SendMessageAsync<PublicKey, GetPublicKey>(new GetPublicKey { CoinName = coinName, AddressNs = path, ShowDisplay = display, ScriptType = inputScriptType });
            return publicKey.Xpub;
        }
        else
        {
            switch (addressType)
            {
                case AddressType.Bitcoin:

                    //Ultra hack to deal with a coin name change in Firmware Version 1.6.2
                    if ((Features.MajorVersion <= 1 && Features.MinorVersion < 6) && coinName == "Bgold")
                    {
                        coinName = "Bitcoin Gold";
                    }

                    return (await SendMessageAsync<Address, GetAddress>(new GetAddress { ShowDisplay = display, AddressNs = path, CoinName = coinName, ScriptType = inputScriptType })).address;

                case AddressType.Ethereum:

                    var ethereumAddress = await SendMessageAsync<EthereumAddress, EthereumGetAddress>(new EthereumGetAddress { ShowDisplay = display, AddressNs = path });

                    var sb = new StringBuilder();
                    foreach (var b in ethereumAddress.Address)
                    {
                        sb.Append(b.ToString("X2").ToLower());
                    }

                    var hexString = sb.ToString();

                    return $"0x{hexString}";
                default:
                    throw new NotImplementedException();
            }
        }
    }
    catch (Exception ex)
    {
        Logger?.Log("Error Getting Trezor Address", LogSection, ex, LogLevel.Error);
        throw;
    }
}