diff --git a/accounts/usbwallet/ledger.go b/accounts/usbwallet/ledger.go index cda94280fdd2..723df0f2b352 100644 --- a/accounts/usbwallet/ledger.go +++ b/accounts/usbwallet/ledger.go @@ -59,6 +59,8 @@ const ( ledgerP1InitTransactionData ledgerParam1 = 0x00 // First transaction data block for signing ledgerP1ContTransactionData ledgerParam1 = 0x80 // Subsequent transaction data block for signing ledgerP2DiscardAddressChainCode ledgerParam2 = 0x00 // Do not return the chain code along with the address + + ledgerEip155Size int = 3 // Size of the EIP-155 chain_id,r,s in unsigned transactions ) // errLedgerReplyInvalidHeader is the error message returned by a Ledger data exchange @@ -347,9 +349,15 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction op = ledgerP1InitTransactionData reply []byte ) + + // Chunk size selection to mitigate an underlying RLP deserialization issue on the ledger app. + // https://github.com/LedgerHQ/app-ethereum/issues/409 + chunk := 255 + for ; len(payload)%chunk <= ledgerEip155Size; chunk-- { + } + for len(payload) > 0 { // Calculate the size of the next data chunk - chunk := 255 if chunk > len(payload) { chunk = len(payload) }