Refuel spots (Marty 2026-11-13, paid from the company fee share): a counted Monthly Refuel of $50+ on either site sends one signed request to Downline Banners to buy a spot for the member's main wallet (sponsor = their network sponsor's wallet), once per tx, with a member notice. Chatbot knows Downline Banners, the Banner Spin button and the refuel spot

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-13 08:55:47 -06:00
parent f20062133f
commit 4e2178d779
3 changed files with 37 additions and 2 deletions
+28
View File
@@ -61,6 +61,33 @@ const bixpay = require('./bixpay'); // BixPay Visa card: partner-link fiel
let follow = null, followStore = null;
const LS_BASE = () => String(process.env.LS_URL || 'https://linkspin.app').replace(/\/+$/, '');
const BL_BASE = () => String(process.env.BL_URL || 'https://downlinebanners.com').replace(/\/+$/, ''); // Downline Banners (network sign-in by wallet, 2026-11-13)
// Refuel spots (Marty 2026-11-13: paid from the company fee share, $50+): refuel.js calls this once per counted $50+ refuel tx
// (either site). Downline Banners buys the spot for the member's main wallet from the engine wallet (its refuelspots.js), with
// their network sponsor's wallet as sponsor. Signed with NETWORK_SSO_SECRET ('net.v1.' + ts + newline + raw body).
async function refuelSpotToBL({ email, site, tx, cents }) {
const a = await accounts.byEmail(email).catch(() => null);
const mask = String(email).replace(/^(.).*(@.*)$/, '$1***$2');
if (!a || !a.address) { console.log('refuel spot: no wallet linked, not sent', mask); return; }
const sp = await accounts.sponsorOf(email).catch(() => null);
const raw = JSON.stringify({ tx, site, cents, wallet: a.address, sponsorWallet: sp && sp.address ? sp.address : null });
const sec = String(process.env.NETWORK_SSO_SECRET || '').trim(); if (sec.length < 32) return;
for (let i = 0; i < 4; i++) {
const ts = String(Date.now()); const sig = crypto.createHmac('sha256', sec).update('net.v1.' + ts + '\n' + raw).digest('hex');
try {
const r = await fetch(BL_BASE() + '/api/partner/refuel-spot', { method: 'POST', body: raw, signal: AbortSignal.timeout(10000), headers: { 'Content-Type': 'application/json', 'X-Net-Ts': ts, 'X-Net-Sig': sig } });
const j = await r.json().catch(() => ({}));
if (r.ok) {
console.log('refuel spot queued on Downline Banners', mask, String(tx).slice(0, 12), j.repeat ? '(repeat)' : '');
if (!j.repeat) await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [a.email], 'Your refuel earned a Downline Banners spot',
'<p>Your $' + (cents / 100).toFixed(0) + ' refuel earned you a free spot on <a href="https://downlinebanners.com/my">Downline Banners</a>, the network banner board. It is being placed in the line for your wallet now.</p><p>Open <a href="https://downlinebanners.com/my">My Spots</a> to add your banner and link (or use one of your LinkSpin Banner Spins). Your InstantAdPay sign-in carries you in.</p>', 'notice').catch(() => {});
return;
}
if (r.status === 400 || r.status === 401) { console.error('refuel spot refused', r.status, j.error || '', mask); return; }
} catch (e) {}
await new Promise(ok => setTimeout(ok, 30000 * (i + 1)));
}
console.error('refuel spot: Downline Banners did not answer', mask, String(tx).slice(0, 12));
}
let activationCache = { at: 0, map: null };
function activationByAddress() { // MemberActivated events by wallet, for the Sponsor check (when the contract bound the sponsor)
if (activationCache.map && Date.now() - activationCache.at < 60000) return activationCache.map;
@@ -655,6 +682,7 @@ async function boot() {
featuredPerDay: () => ads.rates().featuredPerDay || 40,
message: async (to, subject, html) => { await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [to], subject, html, 'notice'); },
badge: (email, key) => postBadgeOnce(email, key, 'Monthly Refuel'),
refuelSpot: refuelSpotToBL, // $50+ counted refuel -> one Downline Banners spot (2026-11-13)
feed: async text => { const sc = siteConfig(); if (!sc.telegramBotToken || !sc.telegramEchoChatId) return false; return telegramSend(sc.telegramEchoChatId, '\u{1F7E0} <b>InstantAdPay</b> \u00b7 ' + text, sc.telegramEchoTopicId); } });
kit.init({ dataDir: DATA_DIR, program: 'iap', publicDir: PUBLIC_DIR, siteUrl: 'https://instantadpay.com',
entitled: async email => { const v = await refuel.view(email); return v && v.on ? { on: true, months: v.kits || {}, nextRefuel: v.refuelDayLabel || null, today: v.today || null } : { on: false }; },