From 700ab055f374aa8973b7a95faad7dfa4f0de1888 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Wed, 18 Sep 2024 14:16:20 +0200 Subject: [PATCH] firmware/btc: return nice error message if silent payments not supported Otherwise an outdated firmware would just return "generic error" when running into such an output. --- api/firmware/btc.go | 4 ++++ api/firmware/btc_test.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api/firmware/btc.go b/api/firmware/btc.go index cd715b2..215ce22 100644 --- a/api/firmware/btc.go +++ b/api/firmware/btc.go @@ -306,6 +306,10 @@ func (device *Device) BTCSign( } } + if containsSilentPaymentOutputs && !device.version.AtLeast(semver.NewSemVer(9, 21, 0)) { + return nil, nil, UnsupportedError("9.21.0") + } + signatures := make([][]byte, len(tx.Inputs)) next, err := device.queryBtcSign(&messages.Request{ Request: &messages.Request_BtcSignInit{ diff --git a/api/firmware/btc_test.go b/api/firmware/btc_test.go index 1d35884..12438ee 100644 --- a/api/firmware/btc_test.go +++ b/api/firmware/btc_test.go @@ -667,7 +667,7 @@ func TestSimulatorBTCSignSilentPayment(t *testing.T) { generatedOutputs, ) } else { - require.Error(t, err) + require.EqualError(t, err, UnsupportedError("9.21.0").Error()) } }) }