Skip to content

Commit

Permalink
deps: update protobuf
Browse files Browse the repository at this point in the history
The module we used previouly, github.com/golang/protobuf/proto, is
deprecated. See https://github.com/golang/protobuf/releases/tag/v1.5.2
and golang/protobuf#1306.

We use the official succssor:

```
(fix imports)
go get google.golang.org/protobuf/proto@v1.28.1
go mod tidy
```

The .pb.go generated files also needed to be updated with an updated
protoc-gen-go:

```
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
```

A new script was added to generate the files, as the
`import_path=messages` flag seems to be removed in favour of the `M`
flag, which unfortunately has to be specified for each .proto file :(

-----------

In `BTCSign()`, the inputs are not copied anymore due to:

```
api/firmware/btc.go:300:20: cannot use &input (value of type **messages.BTCSignInputRequest) as *messages.BTCSignInputRequest value in struct literal (typecheck)
					BtcSignInput: &input,
```
  • Loading branch information
benma committed Aug 16, 2022
1 parent 9c5dd0d commit cdeb9ef
Show file tree
Hide file tree
Showing 21 changed files with 7,719 additions and 4,216 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ tagging versions.

Clone the [BitBox02 firmware repo](https://github.com/digitalbitbox/bitbox02-firmware):

Make sure you have `protoc` and
[protoc-gen-go](https://developers.google.com/protocol-buffers/docs/reference/go-generated)
installed:

`git clone https://github.com/digitalbitbox/bitbox02-firmware.git`

```sh
rm -rf api/firmware/messages/*
rm -rf api/firmware/messages/{*.pb.go,*.proto}
cp /path/to/bitbox02-firmware/messages/*.proto api/firmware/messages/
rm api/firmware/messages/backup.proto
go generate ./...
./api/firmware/messages/generate.sh
```
6 changes: 3 additions & 3 deletions api/firmware/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages"
"github.com/digitalbitbox/bitbox02-api-go/util/errp"
"github.com/digitalbitbox/bitbox02-api-go/util/semver"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
)

const multisigNameMaxLen = 30
Expand Down Expand Up @@ -277,7 +277,7 @@ func (device *Device) BTCSign(
switch next.Type {
case messages.BTCSignNextResponse_INPUT:
inputIndex := next.Index
input := *tx.Inputs[inputIndex].Input
input := tx.Inputs[inputIndex].Input

inputIsSchnorr := isTaproot(scriptConfigs[input.ScriptConfigIndex])

Expand All @@ -297,7 +297,7 @@ func (device *Device) BTCSign(
}
next, err = device.queryBtcSign(&messages.Request{
Request: &messages.Request_BtcSignInput{
BtcSignInput: &input,
BtcSignInput: input,
}})
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion api/firmware/btc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

"github.com/digitalbitbox/bitbox02-api-go/api/firmware/messages"
"github.com/digitalbitbox/bitbox02-api-go/util/semver"
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
)

const hardenedKeyStart = 0x80000000
Expand Down
2 changes: 0 additions & 2 deletions api/firmware/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
"github.com/flynn/noise"
)

//go:generate sh -c "protoc --proto_path=messages/ --go_out='import_path=messages,paths=source_relative:messages' messages/*.proto"

var (
lowestSupportedFirmwareVersion = semver.NewSemVer(9, 0, 0)
lowestSupportedFirmwareVersionBTCOnly = semver.NewSemVer(9, 0, 0)
Expand Down
2 changes: 1 addition & 1 deletion api/firmware/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/digitalbitbox/bitbox02-api-go/api/firmware/mocks"
"github.com/digitalbitbox/bitbox02-api-go/util/semver"
"github.com/flynn/noise"
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
)

// newDevice creates a device to test with, with init/pairing already processed.
Expand Down
Loading

0 comments on commit cdeb9ef

Please # to comment.