bigblocks
Version:
Complete Bitcoin UI component library - authentication, social, wallet, market, inscriptions, and blockchain interactions for React
32 lines (31 loc) • 1.25 kB
JavaScript
// Helper to check if user has wallet capabilities
export function hasWalletCapabilities(user) {
return !!user.paymentKey && !!user.balance;
}
// Helper to safely get wallet properties with defaults
export function getWalletProps(user) {
const walletUser = user;
// Ensure UTXOs have required properties for js-1sat-ord compatibility
const utxos = (walletUser.utxos || []).map((utxo) => ({
...utxo,
script: utxo.script || "", // Provide empty string if missing
}));
const tokenUtxos = (walletUser.tokenUtxos || []).map((utxo) => ({
txid: utxo.txid,
vout: utxo.vout,
script: utxo.script || "",
satoshis: 1, // Token UTXOs always contain exactly 1 satoshi in 1Sat Ordinals protocol
id: utxo.id,
amount: utxo.amount,
amt: utxo.amt || utxo.amount, // Map amount to amt for js-1sat-ord
}));
return {
paymentKey: walletUser.paymentKey,
ordinalKey: walletUser.ordinalKey,
fundingAddress: walletUser.fundingAddress || walletUser.address,
ordinalAddress: walletUser.ordinalAddress || walletUser.address,
balance: walletUser.balance || { confirmed: 0, unconfirmed: 0 },
utxos,
tokenUtxos,
};
}