MCPcopy
hub / github.com/BlueWallet/BlueWallet / _readPsbtFileIntoBase64

Function _readPsbtFileIntoBase64

blue_modules/fs.ts:94–107  ·  view source on GitHub ↗
(uri: string)

Source from the content-addressed store, hash-verified

92};
93
94const _readPsbtFileIntoBase64 = async function (uri: string): Promise<string> {
95 const base64 = await RNFS.readFile(uri, 'base64');
96 const stringData = uint8ArrayToString(base64ToUint8Array(base64)); // decode from base64
97 if (stringData.startsWith('psbt')) {
98 // file was binary, but outer code expects base64 psbt, so we return base64 we got from rn-fs;
99 // most likely produced by Electrum-desktop
100 return base64;
101 } else {
102 // file was a text file, having base64 psbt in there. so we basically have double base64encoded string
103 // thats why we are returning string that was decoded once;
104 // most likely produced by ColdCard
105 return stringData;
106 }
107};
108
109export const showImagePickerAndReadImage = async (): Promise<string | undefined> => {
110 try {

Callers 2

openSignedTransactionFunction · 0.85

Calls 2

uint8ArrayToStringFunction · 0.90
base64ToUint8ArrayFunction · 0.90

Tested by

no test coverage detected