Skip to content

Commit

Permalink
Merge pull request #2512 from kaloudis/passport-debug
Browse files Browse the repository at this point in the history
External account workflow fixes
  • Loading branch information
kaloudis authored Nov 4, 2024
2 parents 2de65b0 + 75f9995 commit f5ff07a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
8 changes: 6 additions & 2 deletions stores/ChannelsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,9 +923,13 @@ export default class ChannelsStore {
};
BackendUtils.openChannelStream(request)
.then((data: any) => {
const { pending_chan_id } = data.result;
const { psbt_fund, pending_chan_id } = data.result;
this.pending_chan_ids.push(pending_chan_id);
this.handleChannelOpen(request);
if (psbt_fund?.funding_address) {
outputs[psbt_fund.funding_address] =
psbt_fund.funding_amount;
}
this.handleChannelOpen(request, outputs);
})
.catch((error: Error) => {
this.handleChannelOpenError(error);
Expand Down
24 changes: 23 additions & 1 deletion views/HandleAnythingQRScanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Header } from 'react-native-elements';
import { observer } from 'mobx-react';
import { URDecoder } from '@ngraveio/bc-ur';
import { StackNavigationProp } from '@react-navigation/stack';
import { CryptoAccount } from '@keystonehq/bc-ur-registry';
import { Bytes, CryptoAccount, CryptoPSBT } from '@keystonehq/bc-ur-registry';

import LoadingIndicator from '../components/LoadingIndicator';
import QRCodeScanner from '../components/QRCodeScanner';
Expand Down Expand Up @@ -137,6 +137,28 @@ export default class HandleAnythingQRScanner extends React.Component<
e
);
}
} else if (ur._type === 'crypto-psbt') {
const data = CryptoPSBT.fromCBOR(ur._cborPayload);
const psbt = data.getPSBT();
handleData = Buffer.from(psbt).toString('base64');
} else if (ur._type === 'bytes') {
const data = Bytes.fromCBOR(ur._cborPayload);
handleData = Buffer.from(data.getData()).toString();

// TODO
// For some reason the cH starting byte from Base64-encoded
// PSBTs is being replaced with a linebreak
if (
handleData.includes('NidP8BA') &&
(handleData.startsWith('\r\n') ||
handleData.startsWith('\n') ||
handleData.startsWith('\r'))
) {
handleData = handleData.replace(
/(\r\n|\n|\r)/gm,
'cH'
);
}
} else {
// Decode the CBOR message to a Buffer
const decoded = ur.decodeCBOR();
Expand Down

0 comments on commit f5ff07a

Please sign in to comment.