-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CryptoProviderFeature: add BYRON so new wallets can disable support
BYRON keypaths are automatically added with the first account to discover BYRON addresses. This works for all current CryptoProviders (Software, Ledger, Trezor). The BitBox02 does not support receiving on legacy Byron addresses and exporting m/44'/... xpubs, so we need a feature flag to indicate that Byron should be turned off when a BitBox02 is used as the CryptoProvider. add BitBox02 hardware wallet support Co-authored-by: thisconnect <[email protected]> bitbox02: display pairing code bitbox02: add types for the bitbox02-api dependency They will eventually be upstreamed. Excluded from eslint because eslint expects Javascript, not pure Typescript (e.g. it can't parse the constructor type without a body). bitbox02: close an existing connection before opening a new one Same as with getLedgerTransport in the Ledger crypto provider. This ensures logout followed by another login works. upgrade from webpack 4 to webpack 5 We want to dynamically import the bitbox02-api package and split it out of the main bundle. After many different attempts we only found that it works when upgrading to webpack 5, hence this commit. The upgrade was performed by following https://webpack.js.org/migrate/5/. The `require.resolve('...`) additions were upgrade fixes suggested by webpack itself on the command line. Other references used: webpack/changelog-v5#10 (comment) https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined bitbox02: lazily load bitbox02-api and split code out of main bundle Since the bitbox02-api package is quite heavy, we only want to load it when actually unlocking a BitBox02. We follow the third approach described in https://webpack.js.org/guides/code-splitting: using `await import(...)` to load the package on demand, which also automatically splits the code into a new file. The `webpackChunkName: "bitbox02-api"` describes the name of the new file in dist/js/. The tsconfig change was needed for code splitting to kick in, according to: - webpack/webpack#5703 (comment) - webpack/webpack#5703 (comment) poolOwner: restrict to Trezor/Ledger
- Loading branch information
Showing
34 changed files
with
1,189 additions
and
1,366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
app/bitbox02-api.d.ts | ||
app/dist/ | ||
app/tests/dist/ | ||
app/node_modules/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
declare module 'bitbox02-api' { | ||
export function getDevicePath(options?: {forceBridge: boolean}): string | ||
|
||
type CardanoNetwork = 0 | 1 | ||
|
||
export const constants = { | ||
Status: { | ||
PairingFailed: string, | ||
}, | ||
Product: { | ||
BitBox02Multi: string, | ||
BitBox02BTCOnly: string, | ||
}, | ||
messages: { | ||
CardanoNetwork: { | ||
CardanoMainnet: CardanoNetwork, | ||
CardanoTestnet: CardanoNetwork, | ||
}, | ||
}, | ||
} | ||
|
||
declare class Firmware { | ||
Product(): string | ||
} | ||
|
||
type Keypath = number[] | ||
type ScriptConfig = { | ||
pkhSkh: { | ||
keypathPayment: Keypath | ||
keypathStake: Keypath | ||
} | ||
} | ||
|
||
type CardanoInput = { | ||
keypath: Keypath | ||
prevOutHash: Uint8Array | ||
prevOutIndex: number | ||
} | ||
|
||
type CardanoOutput = { | ||
encodedAddress: string | ||
value: string | ||
scriptConfig?: ScriptConfig | ||
} | ||
|
||
type CardanoCertificate = | ||
| { | ||
stakeRegistration: { | ||
keypath: Keypath | ||
} | ||
} | ||
| { | ||
stakeDeregistration: { | ||
keypath: Keypath | ||
} | ||
} | ||
| { | ||
stakeDelegation: { | ||
keypath: Keypath | ||
poolKeyhash: Uint8Array | ||
} | ||
} | ||
|
||
type CardanoWithdrawal = { | ||
keypath: Keypath | ||
value: string | ||
} | ||
|
||
type CardanoShelleyWitness = { | ||
signature: Uint8Array | ||
publicKey: Uint8Array | ||
} | ||
|
||
export declare class BitBox02API { | ||
constructor(devicePath: string) | ||
connect( | ||
showPairingCb: (string) => void, | ||
userVerify: () => Promise<void>, | ||
handleAttestationCb: (bool) => void, | ||
onCloseCb: () => void, | ||
setStatusCb: (string) => void | ||
) | ||
close(): boolean | ||
firmware(): Firmware | ||
version(): string | ||
cardanoXPubs(keypaths: Keypath[]): Promise<Uint8Array[]> | ||
cardanoAddress( | ||
network: CardanoNetwork, | ||
scriptConfig: ScriptConfig, | ||
display?: boolean | ||
): Promise<string> | ||
cardanoSignTransaction(params: { | ||
network: CardanoNetwork | ||
inputs: CardanoInput[] | ||
outputs: CardanoOutput[] | ||
fee: string | ||
ttl: string | ||
certificates: CardanoCertificate[] | ||
withdrawals: CardanoWithdrawal[] | ||
validityIntervalStart: string | ||
}): Promise<{ | ||
shelleyWitnesses: CardanoShelleyWitness[] | ||
}> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.