View-Only Wallets
RAILGUN Wallets (created with mnemonic) have both spending and viewing keys. View-Only wallets lack the spending key, so they cannot create transactions, but they have access to the wallet viewing key that can access balances and transaction history.
View-Only wallets are created using a shareable viewing key. Only the original wallet owner, who has access to the RAILGUN Wallet (and mnemonic) can generate a shareable key.
import {
getWalletShareableViewingKey,
createViewOnlyRailgunWallet,
} from '@railgun-community/wallet';
const shareableViewingKey = await getWalletShareableViewingKey(railgunWalletID);
...
// Current block numbers for each chain when wallet was first created.
// If unknown, provide undefined.
const creationBlockNumberMap: Optional<MapType<number>> = undefined;
const viewOnlyWalletInfo = await createViewOnlyRailgunWallet(
encryptionKey,
shareableViewingKey,
creationBlockNumberMap,
);
const id = viewOnlyWalletInfo.id;
View-Only wallets may be loaded like RAILGUN Wallets, using
loadWalletByID
.import { loadWalletByID } from '@railgun-community/quickstart';
const viewOnlyWalletInfo = await loadWalletByID(
encryptionKey,
id,
true, // isViewOnlyWallet
);
Last modified 3mo ago