Skip to content

Commit

Permalink
FIX: add fix to issue #21 (change path to BIP44)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbegin committed Jul 28, 2018
1 parent 6cd8856 commit b794324
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions keys/Ledger/ledger.red
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,18 @@ ledger: context [
]
]

get-eth-address: func [idx [block!] /local data pub-key-len addr-len][
get-eth-address: func [ids [block!] /local data pub-key-len addr-len][
data: make binary! 20
append data reduce [
E0h
02h
0
0
4 * 5 + 1
5
to-bin32 idx/1
to-bin32 idx/2
to-bin32 idx/3
to-bin32 idx/4
to-bin32 idx/5
4 * (length? ids) + 1
]
append data collect [
keep length? ids
forall ids [keep to-bin32 ids/1]
]
write-apdu data
data: read-apdu 1
Expand All @@ -202,7 +200,7 @@ ledger: context [
]
]

sign-eth-tx: func [addr-idx [block!] tx [block!] /local data max-sz sz signed][
sign-eth-tx: func [ids [block!] tx [block!] /local data max-sz sz signed][
;-- tx: [nonce, gasprice, startgas, to, value, data]
tx-bin: rlp/encode tx
chunk: make binary! 200
Expand All @@ -215,14 +213,11 @@ ledger: context [
chunk/2: 04h
chunk/3: either head? tx-bin [0][80h]
chunk/4: 0
chunk/5: either head? tx-bin [sz + 17][sz]
chunk/5: either head? tx-bin [sz + (4 * (length? ids) + 1)][sz]
if head? tx-bin [
append chunk reduce [
4
to-bin32 addr-idx/1
to-bin32 addr-idx/2
to-bin32 addr-idx/3
to-bin32 addr-idx/4
append chunk collect [
keep length? ids
forall ids [keep to-bin32 ids/1]
]
]
append/part chunk tx-bin sz
Expand All @@ -234,8 +229,8 @@ ledger: context [
either 4 > length? signed [none][signed]
]

get-eth-signed-data: func [idx tx /local signed][
signed: sign-eth-tx idx tx
get-eth-signed-data: func [ids tx /local signed][
signed: sign-eth-tx ids tx
either all [signed binary? signed][
append tx reduce [
copy/part signed 1
Expand Down

0 comments on commit b794324

Please sign in to comment.