SHA256
Добавить страницу донатов канала
This commit is contained in:
@@ -64,11 +64,16 @@ export function makeShineChannelAboutRoute({ ownerBlockchainName = '', channelRo
|
||||
return base ? `${base}/about` : '';
|
||||
}
|
||||
|
||||
export function makeShineChannelShortRoute({ ownerBlockchainName = '', channelName = '' }) {
|
||||
const ownerBch = String(ownerBlockchainName || '').trim();
|
||||
export function makeShineChannelDonateRoute({ ownerBlockchainName = '', channelRootBlockNumber = '', channelRootBlockHash = '' }) {
|
||||
const base = makeShineChannelRootRoute({ ownerBlockchainName, channelRootBlockNumber, channelRootBlockHash });
|
||||
return base ? `${base}/donate` : '';
|
||||
}
|
||||
|
||||
export function makeShineChannelShortRoute({ ownerLogin = '', ownerBlockchainName = '', channelName = '' }) {
|
||||
const cleanOwnerLogin = normalizeLogin(ownerLogin) || extractLoginFromBlockchainName(ownerBlockchainName);
|
||||
const chName = String(channelName || '').trim();
|
||||
if (!ownerBch || !chName) return '';
|
||||
return `${encodeRoutePart(ownerBch)}/${encodeRoutePart(chName)}`;
|
||||
if (!cleanOwnerLogin || !chName) return '';
|
||||
return `${encodeRoutePart(cleanOwnerLogin)}/${encodeRoutePart(chName)}`;
|
||||
}
|
||||
|
||||
export function makeShineMessageRoute({ ownerLogin = '', messageBlockchainName = '', messageBlockNumber = '' }) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { extractClientKey32FromStoredValue } from './client-key-utils.js';
|
||||
import { base64ToBytes } from './crypto-utils.js';
|
||||
import { loadEncryptedUserSecrets } from './key-vault.js';
|
||||
import { SOLANA_ENDPOINT_DEFAULT } from '../solana-programs.js';
|
||||
import { loadSolanaWeb3 } from '../vendor/solana-web3-loader.js';
|
||||
@@ -45,6 +46,17 @@ function encodeBase58(bytesLike) {
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
export function solanaAddressFromPublicKeyBase64(publicKeyB64) {
|
||||
const clean = String(publicKeyB64 || '').trim();
|
||||
if (!clean) return '';
|
||||
const bytes = base64ToBytes(clean);
|
||||
if (bytes.length !== 32) {
|
||||
throw new Error('Публичный ключ Solana должен содержать 32 байта');
|
||||
}
|
||||
return encodeBase58(bytes);
|
||||
}
|
||||
|
||||
function normalizeEndpoint(url) {
|
||||
const raw = String(url || '').trim();
|
||||
if (!raw) return DEFAULT_SOLANA_ENDPOINT;
|
||||
@@ -110,6 +122,17 @@ async function keypairFromStoredSecret(storedSecret) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function getSolanaWalletFromStoredSecret(storedSecret) {
|
||||
const clean = String(storedSecret || '').trim();
|
||||
if (!clean) throw new Error('Не передан приватный ключ');
|
||||
const keypair = await keypairFromStoredSecret(clean);
|
||||
return {
|
||||
address: keypair.publicKey.toBase58(),
|
||||
keypair,
|
||||
};
|
||||
}
|
||||
|
||||
export async function createRandomSolanaWallet() {
|
||||
const solana = await loadSolanaLib();
|
||||
const keypair = solana.Keypair.generate();
|
||||
|
||||
Reference in New Issue
Block a user