shapeshift / lib

MIT License
22 stars 54 forks source link

fix: keepkey swaps from RUNE #1231

Closed BitHighlander closed 1 year ago

BitHighlander commented 1 year ago

Fixes swaps from RUNE when using a KeepKey. Uses "THOR.RUNE" as a thorchain/MsgDeposit MsgType coin asset, as defined in the THORChain protocol:

https://dev.thorchain.org/thorchain-dev/concepts/memos#asset-notation

The reason is hdwallet-keepkey has stronger validation, and the rune coin asset we currently use doesn't pass validation there:

https://github.com/shapeshift/hdwallet/blob/925de40aac9a2e3cafe09c5f33f5cc42417461bd/packages/hdwallet-keepkey/src/thorchain.ts#L96-L98

See the shape of a "valid" message (in hdwallet-keepkey terms) here: https://github.com/shapeshift/hdwallet/blob/925de40aac9a2e3cafe09c5f33f5cc42417461bd/integration/src/thorchain/tx01.mainnet.thorchain.swap.json#L15-L29

Note that this is NOT a limitation of the network. This is actually an arbitrary check of hdwallet-keepkey, and both rune and THOR.RUNE are actually valid variants in the Thorchain world, see: https://gitlab.com/thorchain/thornode/-/blob/622179d8bf966f7a14ea8074e521914461d521ce/common/asset_test.go#L31-33

Unfortunately, confirmed by monkey-patching hdwallet-keepkey to allow rune instead of THOR.RUNE that KeepKey produces an invalid signature while using the rune variant, which seems to indicate a firmware arbitrary limitation.

shapeshift-ci-bot commented 1 year ago

:tada: This PR is included in version @shapeshiftoss/chain-adapters-v11.2.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: