--- /dev/null
+(define-module (infiniteadaptability bitcoin)
+ #:use-module (guix build-system pyproject)
+ #:use-module (guix build-system python)
+ #:use-module (guix download)
+ #:use-module (guix git-download)
+ #:use-module ((guix licenses)
+ #:prefix license:)
+ #:use-module (guix packages)
+ #:use-module (gnu packages)
+ #:use-module (gnu packages check)
+ #:use-module (gnu packages finance)
+ #:use-module (gnu packages libusb)
+ #:use-module (gnu packages linux)
+ #:use-module (gnu packages protobuf)
+ #:use-module (gnu packages python)
+ #:use-module (gnu packages python-build)
+ #:use-module (gnu packages python-crypto)
+ #:use-module (gnu packages python-xyz)
+ #:use-module (gnu packages serialization))
+
+(define-public hwi
+ (package
+ (name "hwi")
+ (version "2.3.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/bitcoin-core/hwi")
+ (commit version)))
+ (sha256
+ (base32 "00sdzj0rmir9hppi994a6r8w41lwm0jfncihj8yd8f42i43md02p"))
+ (file-name (git-file-name name version))))
+ (build-system pyproject-build-system)
+ (arguments
+ (list
+ #:tests? #f))
+ (propagated-inputs (list python-ecdsa
+ python-cbor
+ python-hidapi-0.14.0
+ python-libusb1
+ python-mnemonic
+ python-noiseprotocol
+ python-protobuf-4.25.2
+ python-pyaes
+ python-pyserial
+ python-semver-3.0.2
+ python-typing-extensions))
+ (inputs (list libusb eudev trezord-udev-rules))
+ (native-inputs (list poetry python-pytest))
+ (home-page "https://github.com/bitcoin-core/hwi")
+ (synopsis "Command line tool for interacting with hardware wallets")
+ (description
+ "Provides a standard way for software to work with hardware wallets without needing to implement device specific drivers")
+ (license license:expat)))
+
+(define-public python-noiseprotocol
+ (package
+ (name "python-noiseprotocol")
+ (version "0.3.1")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "noiseprotocol" version))
+ (sha256
+ (base32 "0ifnj0mpbqsfqba9n12vf5yzxj4qf2gxql3ry43qyshgnrqsi4mh"))))
+ (build-system pyproject-build-system)
+ (propagated-inputs (list python-cryptography))
+ (home-page "https://github.com/plizonczyk/noiseprotocol")
+ (synopsis "Implementation of Noise Protocol Framework")
+ (description "Implementation of Noise Protocol Framework")
+ (license license:expat)))
+
+(define python-semver-3.0.2
+ (package
+ (inherit python-semver)
+ (version "3.0.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "semver" version))
+ (sha256
+ (base32 "1k5lba437cgzkr5zp230508w856lpi973ynjzqdfbxkhkjrsslv2"))))
+ (build-system pyproject-build-system)))
+
+(define python-protobuf-4.25.2
+ (package
+ (inherit python-protobuf)
+ (version "4.25.2")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "protobuf" version))
+ (sha256
+ (base32 "0phabz0rb6dqrk79wmhf5hkgf49dj15wsjsjxv4fyixkbhbrwngy"))))
+ (arguments
+ (list
+ #:tests? #f))))
+
+(define python-hidapi-0.14.0
+ (package
+ (inherit python-hidapi)
+ (version "0.14.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "hidapi" version))
+ (sha256
+ (base32 "1gmq2akd3hqmhr9w4a8sf04n9101jmnm51hj71m45mffhs905jx7"))
+ (modules '((guix build utils)))
+ (snippet
+ ;; Remove bundled libraries.
+ '(begin
+ (delete-file-recursively "hidapi") #t))))
+ (arguments
+ `(#:phases (modify-phases %standard-phases
+ (add-after 'unpack 'patch-configuration
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "setup.py"
+ (("\"/usr/include/libusb-1.0\"")
+ (string-append "\""
+ (assoc-ref inputs "libusb")
+ "/include/libusb-1.0\""))
+ (("\"/usr/include/hidapi\"")
+ (string-append "\""
+ (assoc-ref inputs "hidapi")
+ "/include/hidapi\""))) #t))
+ ;; XXX Necessary because python-build-system drops the arguments.
+ (replace 'build
+ (lambda _
+ (invoke "python" "setup.py" "build"
+ "--with-system-hidapi")))
+ (replace 'check
+ (lambda _
+ (invoke "python" "setup.py" "test"
+ "--with-system-hidapi")))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (invoke "python"
+ "setup.py"
+ "install"
+ "--with-system-hidapi"
+ (string-append "--prefix="
+ (assoc-ref outputs "out"))
+ "--single-version-externally-managed"
+ "--root=/"))))))))
+
+hwi