Skip to content

Commit

Permalink
bitbox02: display pairing code
Browse files Browse the repository at this point in the history
  • Loading branch information
benma authored and refi93 committed Nov 22, 2021
1 parent 90c9202 commit 28ca6aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 9 additions & 1 deletion app/frontend/actions/wallet.ts
Expand Up @@ -49,7 +49,7 @@ const accountsIncludeStakingAddresses = (
}

export default (store: Store) => {
const {loadingAction} = loadingActions(store)
const {loadingAction, stopLoadingAction} = loadingActions(store)
const {setError} = errorActions(store)
const {getState, setState} = store

Expand Down Expand Up @@ -103,11 +103,19 @@ export default (store: Store) => {
ledgerTransportChoice === LedgerTransportChoice.DEFAULT
? await getDefaultLedgerTransportType()
: ledgerTransportChoice
const bitbox02OnPairingCode = (pairingCode: string) => {
if (pairingCode !== null) {
loadingAction(state, `BitBox02 pairing code:\n${pairingCode}`)
} else {
stopLoadingAction(state)
}
}
const config = {
...ADALITE_CONFIG,
isShelleyCompatible,
shouldExportPubKeyBulk,
ledgerTransportType,
bitbox02OnPairingCode,
}

try {
Expand Down
Expand Up @@ -53,9 +53,11 @@ const ShelleyBitBox02CryptoProvider = async ({
bitbox02 = new BitBox02API(devicePath)
await bitbox02.connect(
(pairingCode) => {
/* TODO */
config.bitbox02OnPairingCode(pairingCode)
},
() => {
config.bitbox02OnPairingCode(null)
},
() => {},
(attestationResult) => {
debugLog(`BitBox02 attestation: ${attestationResult}`)
},
Expand All @@ -64,7 +66,7 @@ const ShelleyBitBox02CryptoProvider = async ({
},
(status) => {
if (status === bitbox02Constants.Status.PairingFailed) {
throw new Error('Pairing failed')
config.bitbox02OnPairingCode(null)
}
}
)
Expand Down

0 comments on commit 28ca6aa

Please sign in to comment.