Skip to content

Files

Latest commit

Jul 4, 2024
dcff6ce · Jul 4, 2024

History

History

BTCPayServer.Hwi

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jul 4, 2024
Nov 26, 2019
Jan 23, 2024
Jan 23, 2024
Jan 23, 2024
Sep 8, 2021
Oct 29, 2019
Oct 27, 2019
Sep 8, 2021
Sep 8, 2021
Oct 26, 2019
Oct 26, 2019
May 27, 2021
Oct 26, 2019
Sep 8, 2021
Nov 26, 2019
Jun 30, 2020
Jun 20, 2022

NuGet

How to use BTCPayServer.Hwi

First, you need to reference the nuget package in your project.

using System;
using System.Linq;
using System.Threading.Tasks;
using BTCPayServer.Hwi;
using BTCPayServer.Hwi.Deployment;
using NBitcoin;

namespace BTCPayServer.Vault
{
    class Program
    {
        static async Task Main(string[] args)
        {
            // This line will download hwi program in the process current directory
            await HwiVersions.v1_1_2.Current.EnsureIsDeployed();

            var hwiClient = new HwiClient(Network.Main);

            // Enumerate the harware wallets on this computer
            // If your device is not detected and you are on linux,
            // make sure that you properly applied udev rules.
            // These are necessary for the devices to be reachable on Linux environments.
            // See https://github.com/bitcoin-core/HWI/tree/master/hwilib/udev
            var device = (await hwiClient.EnumerateDevicesAsync()).First();

            // Ask the device to display the segwit address on the BIP32 path "84'/0'/0'/0/0"
            await device.DisplayAddressAsync(ScriptPubKeyType.Segwit, new KeyPath("84'/0'/0'/0/0"));
        }
    }
}

You can find some other example on how to use this library in BTCPayServer.Vault.Tests/HwiTests.cs.

Licence

This project is under MIT License.

Special thanks

Special thanks to Wasabi Wallet, this code is based on their work, and as well to the bitcoin developers and achow101 for the HWI Project.