Skip to content

Commit

Permalink
bitbox02: display pairing code
Browse files Browse the repository at this point in the history
  • Loading branch information
benma committed Oct 26, 2021
1 parent 87d14cb commit 7ab6146
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 @@ -38,7 +38,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 @@ -91,11 +91,19 @@ export default (store: Store) => {
selectedLedgerTransportType === LedgerTransportType.DEFAULT
? await getDefaultLedgerTransportType()
: selectedLedgerTransportType
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 @@ -40,9 +40,11 @@ const ShelleyBitBox02CryptoProvider = async ({
try {
await bitbox02.connect(
(pairingCode) => {
/* TODO */
config.bitbox02OnPairingCode(pairingCode)
},
() => {
config.bitbox02OnPairingCode(null)
},
() => {},
(attestationResult) => {
debugLog(`BitBox02 attestation: ${attestationResult}`)
},
Expand All @@ -51,7 +53,7 @@ const ShelleyBitBox02CryptoProvider = async ({
},
(status) => {
if (status === bitbox02Constants.Status.PairingFailed) {
throw new Error('Pairing failed')
config.bitbox02OnPairingCode(null)
}
}
)
Expand Down

0 comments on commit 7ab6146

Please sign in to comment.