Skip to content

Commit b394e56

Browse files
committed
Merge branch 'cedwies/coin-purchase-memo'
2 parents 27acdb0 + 8be5c62 commit b394e56

8 files changed

Lines changed: 648 additions & 159 deletions

File tree

api/firmware/eth.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ func (device *Device) ETHSign(
211211
}
212212

213213
// ETHSignEIP1559 signs an ethereum EIP1559 transaction. It returns a 65 byte signature (R, S, and 1 byte recID).
214+
// If paymentRequest is provided, firmware v9.26.0 or newer is required.
214215
func (device *Device) ETHSignEIP1559(
215216
chainID uint64,
216217
keypath []uint32,
@@ -221,11 +222,16 @@ func (device *Device) ETHSignEIP1559(
221222
recipient [20]byte,
222223
value *big.Int,
223224
data []byte,
224-
recipientAddressCase messages.ETHAddressCase) ([]byte, error) {
225+
recipientAddressCase messages.ETHAddressCase,
226+
paymentRequest *messages.BTCPaymentRequestRequest,
227+
) ([]byte, error) {
225228

226229
if !device.version.AtLeast(semver.NewSemVer(9, 16, 0)) {
227230
return nil, UnsupportedError("9.16.0")
228231
}
232+
if paymentRequest != nil && !device.version.AtLeast(semver.NewSemVer(9, 26, 0)) {
233+
return nil, UnsupportedError("9.26.0")
234+
}
229235

230236
hostNonceCommitment, hostNonce, err := handleHostNonceCommitment()
231237
if err != nil {
@@ -246,6 +252,7 @@ func (device *Device) ETHSignEIP1559(
246252
Data: data,
247253
HostNonceCommitment: hostNonceCommitment,
248254
AddressCase: recipientAddressCase,
255+
PaymentRequest: paymentRequest,
249256
},
250257
},
251258
}

api/firmware/eth_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ func TestSimulatorETHSignEIP1559(t *testing.T) {
486486
value,
487487
nil,
488488
messages.ETHAddressCase_ETH_ADDRESS_CASE_MIXED,
489+
nil,
489490
)
490491
require.NoError(t, err)
491492

api/firmware/messages/btc.pb.go

Lines changed: 301 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/firmware/messages/btc.proto

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,27 @@ message BTCPaymentRequestRequest {
246246
message TextMemo {
247247
string note = 1;
248248
}
249+
message CoinPurchaseMemo {
250+
uint32 coin_type = 1; // SLIP-44 coin type
251+
string amount = 2; // Human-readable amount (e.g. "0.25 ETH")
252+
string address = 3; // Address to send the purchased coins to
253+
// Derivation info for verifying address ownership.
254+
// NOT part of the SLIP-24 sighash.
255+
message EthAddressDerivation {
256+
repeated uint32 keypath = 1; // Keypath to the address
257+
}
258+
message BtcAddressDerivation {
259+
// Script config + keypath are needed to derive BTC/LTC-family addresses.
260+
BTCScriptConfigWithKeypath script_config = 1;
261+
}
262+
oneof address_derivation {
263+
EthAddressDerivation eth = 4;
264+
BtcAddressDerivation btc = 5;
265+
}
266+
}
249267
oneof memo {
250268
TextMemo text_memo = 1;
269+
CoinPurchaseMemo coin_purchase_memo = 2;
251270
}
252271
}
253272

0 commit comments

Comments
 (0)