aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tb.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-03-16 16:35:11 -0700
committerAdam Soltys <[email protected]>2026-03-16 16:37:03 -0700
commit8c1385eaf8e68ef0ad436ad9b74e5813e92bb378 (patch)
tree16edd2c353a5d435768f901063fa146e97536d83 /lib/tb.ts
parent4a3d3b676ec7c21077786c7cdd33772385b87a6d (diff)
downloadcoinos-server-8c1385eaf8e68ef0ad436ad9b74e5813e92bb378.tar.gz
coinos-server-8c1385eaf8e68ef0ad436ad9b74e5813e92bb378.zip
update migrate script
Diffstat (limited to 'lib/tb.ts')
-rw-r--r--lib/tb.ts49
1 files changed, 0 insertions, 49 deletions
diff --git a/lib/tb.ts b/lib/tb.ts
index 9fbff6c8..aa758bef 100644
--- a/lib/tb.ts
+++ b/lib/tb.ts
@@ -671,52 +671,3 @@ export async function getFundBalance(name: string): Promise<number | null> {
return accountBalance(account);
}
-// Migration helper: multiply existing balance by MULTIPLIER to convert sats→microsats
-// Called by migrateToMicrosats() - adds (balance * 999999) to turn X into X*1000000
-// NOTE: This migration should only run ONCE - guarded by tb:microsats flag in migrate.ts
-export async function tbMultiplyForMicrosats(uid: string): Promise<number> {
- // Ensure client is initialized (needed when called during startup)
- if (!client) {
- await initTigerBeetle();
- }
-
- const MULTIPLIER = 999999n; // Adding this turns X into X*1000000
- let count = 0;
-
- const multiplyAccount = async (accountId: bigint, ledger: number, houseId: bigint) => {
- const acct = await client.lookupAccounts([u128(accountId)]);
- if (!acct.length) return;
- const current = BigInt(acct[0].credits_posted) - BigInt(acct[0].debits_posted);
- if (current <= 0n) return;
-
- const results = await client.createTransfers([
- {
- id: nextTransferId(),
- debit_account_id: u128(houseId),
- credit_account_id: u128(accountId),
- amount: current * MULTIPLIER,
- pending_id: 0n,
- user_data_128: 0n,
- user_data_64: 0n,
- user_data_32: 0,
- timeout: 0,
- ledger,
- code: 1,
- flags: 0,
- timestamp: 0n,
- },
- ]);
- if (results.length === 0) count++;
- };
-
- const balId = balanceId(uid);
- const pendId = pendingId(uid);
-
- await multiplyAccount(balId, LEDGER_SATS, HOUSE_SATS);
- await multiplyAccount(pendId, LEDGER_SATS, HOUSE_SATS);
- await multiplyAccount(creditId(uid, "bitcoin"), LEDGER_CREDIT_BTC, HOUSE_BTC);
- await multiplyAccount(creditId(uid, "lightning"), LEDGER_CREDIT_LN, HOUSE_LN);
- await multiplyAccount(creditId(uid, "liquid"), LEDGER_CREDIT_LQ, HOUSE_LQ);
-
- return count;
-}