backup schema WIP

This commit is contained in:
Florian Dold 2020-12-07 22:54:36 +01:00
parent bd88f3f443
commit e78df9b6b1
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
3 changed files with 657 additions and 304 deletions

View File

@ -30,7 +30,7 @@ import {
BackupCoinSource, BackupCoinSource,
BackupCoinSourceType, BackupCoinSourceType,
BackupDenomination, BackupDenomination,
BackupExchangeData, BackupExchange,
BackupExchangeWireFee, BackupExchangeWireFee,
WalletBackupContentV1, WalletBackupContentV1,
} from "../types/backupTypes"; } from "../types/backupTypes";
@ -134,7 +134,7 @@ export async function exportBackup(
async (tx) => { async (tx) => {
const bs = await getWalletBackupState(ws, tx); const bs = await getWalletBackupState(ws, tx);
const exchanges: BackupExchangeData[] = []; const exchanges: BackupExchange[] = [];
const coins: BackupCoin[] = []; const coins: BackupCoin[] = [];
const denominations: BackupDenomination[] = []; const denominations: BackupDenomination[] = [];
@ -159,18 +159,18 @@ export async function exportBackup(
Object.keys(wi.feesForType).forEach((x) => { Object.keys(wi.feesForType).forEach((x) => {
for (const f of wi.feesForType[x]) { for (const f of wi.feesForType[x]) {
wireFees.push({ wireFees.push({
wireType: x, wire_type: x,
closingFee: Amounts.stringify(f.closingFee), closing_fee: Amounts.stringify(f.closingFee),
endStamp: f.endStamp, end_stamp: f.endStamp,
sig: f.sig, sig: f.sig,
startStamp: f.startStamp, start_stamp: f.startStamp,
wireFee: Amounts.stringify(f.wireFee), wire_fee: Amounts.stringify(f.wireFee),
}); });
} }
}); });
exchanges.push({ exchanges.push({
baseUrl: ex.baseUrl, base_url: ex.baseUrl,
accounts: ex.wireInfo.accounts.map((x) => ({ accounts: ex.wireInfo.accounts.map((x) => ({
paytoUri: x.payto_uri, paytoUri: x.payto_uri,
})), })),
@ -179,38 +179,38 @@ export async function exportBackup(
auditorUrl: x.auditor_url, auditorUrl: x.auditor_url,
denominationKeys: x.denomination_keys, denominationKeys: x.denomination_keys,
})), })),
masterPublicKey: ex.details.masterPublicKey, master_public_key: ex.details.masterPublicKey,
currency: ex.details.currency, currency: ex.details.currency,
protocolVersion: ex.details.protocolVersion, protocol_version: ex.details.protocolVersion,
wireFees, wire_fees: wireFees,
signingKeys: ex.details.signingKeys.map((x) => ({ signing_keys: ex.details.signingKeys.map((x) => ({
key: x.key, key: x.key,
masterSig: x.master_sig, masterSig: x.master_sig,
stampEnd: x.stamp_end, stampEnd: x.stamp_end,
stampExpire: x.stamp_expire, stampExpire: x.stamp_expire,
stampStart: x.stamp_start, stampStart: x.stamp_start,
})), })),
termsOfServiceAcceptedEtag: ex.termsOfServiceAcceptedEtag, tos_etag_accepted: ex.termsOfServiceAcceptedEtag,
termsOfServiceLastEtag: ex.termsOfServiceLastEtag, tos_etag_last: ex.termsOfServiceLastEtag,
}); });
}); });
await tx.iter(Stores.denominations).forEach((denom) => { await tx.iter(Stores.denominations).forEach((denom) => {
denominations.push({ denominations.push({
denomPub: denom.denomPub, denom_pub: denom.denomPub,
denomPubHash: denom.denomPubHash, denom_pub_hash: denom.denomPubHash,
exchangeBaseUrl: canonicalizeBaseUrl(denom.exchangeBaseUrl), exchangeBaseUrl: canonicalizeBaseUrl(denom.exchangeBaseUrl),
feeDeposit: Amounts.stringify(denom.feeDeposit), fee_deposit: Amounts.stringify(denom.feeDeposit),
feeRefresh: Amounts.stringify(denom.feeRefresh), fee_refresh: Amounts.stringify(denom.feeRefresh),
feeRefund: Amounts.stringify(denom.feeRefund), fee_refund: Amounts.stringify(denom.feeRefund),
feeWithdraw: Amounts.stringify(denom.feeWithdraw), fee_withdraw: Amounts.stringify(denom.feeWithdraw),
isOffered: denom.isOffered, is_offered: denom.isOffered,
isRevoked: denom.isRevoked, is_revoked: denom.isRevoked,
masterSig: denom.masterSig, master_sig: denom.masterSig,
stampExpireDeposit: denom.stampExpireDeposit, stamp_expire_deposit: denom.stampExpireDeposit,
stampExpireLegal: denom.stampExpireLegal, stamp_expire_legal: denom.stampExpireLegal,
stampExpireWithdraw: denom.stampExpireWithdraw, stamp_expire_withdraw: denom.stampExpireWithdraw,
stampStart: denom.stampStart, stamp_start: denom.stampStart,
value: Amounts.stringify(denom.value), value: Amounts.stringify(denom.value),
}); });
}); });
@ -221,40 +221,40 @@ export async function exportBackup(
case CoinSourceType.Refresh: case CoinSourceType.Refresh:
bcs = { bcs = {
type: BackupCoinSourceType.Refresh, type: BackupCoinSourceType.Refresh,
oldCoinPub: coin.coinSource.oldCoinPub, old_coin_pub: coin.coinSource.oldCoinPub,
}; };
break; break;
case CoinSourceType.Tip: case CoinSourceType.Tip:
bcs = { bcs = {
type: BackupCoinSourceType.Tip, type: BackupCoinSourceType.Tip,
coinIndex: coin.coinSource.coinIndex, coin_index: coin.coinSource.coinIndex,
walletTipId: coin.coinSource.walletTipId, wallet_tip_id: coin.coinSource.walletTipId,
}; };
break; break;
case CoinSourceType.Withdraw: case CoinSourceType.Withdraw:
bcs = { bcs = {
type: BackupCoinSourceType.Withdraw, type: BackupCoinSourceType.Withdraw,
coinIndex: coin.coinSource.coinIndex, coin_index: coin.coinSource.coinIndex,
reservePub: coin.coinSource.reservePub, reserve_pub: coin.coinSource.reservePub,
withdrawalGroupId: coin.coinSource.withdrawalGroupId, withdrawal_group_id: coin.coinSource.withdrawalGroupId,
}; };
break; break;
} }
coins.push({ coins.push({
exchangeBaseUrl: coin.exchangeBaseUrl, exchangeBaseUrl: coin.exchangeBaseUrl,
blindingKey: coin.blindingKey, blinding_key: coin.blindingKey,
coinPriv: coin.coinPriv, coin_priv: coin.coinPriv,
coinPub: coin.coinPub, coin_pub: coin.coinPub,
coinSource: bcs, coin_source: bcs,
currentAmount: Amounts.stringify(coin.currentAmount), current_amount: Amounts.stringify(coin.currentAmount),
fresh: coin.status === CoinStatus.Fresh, fresh: coin.status === CoinStatus.Fresh,
}); });
}); });
const backupBlob: WalletBackupContentV1 = { const backupBlob: WalletBackupContentV1 = {
schemaId: "gnu-taler-wallet-backup", schema_id: "gnu-taler-wallet-backup",
schemaVersion: 1, schema_version: 1,
clock: bs.clock, clock: bs.clock,
coins: coins, coins: coins,
exchanges: exchanges, exchanges: exchanges,
@ -262,7 +262,7 @@ export async function exportBackup(
refreshSessions: [], refreshSessions: [],
reserves: [], reserves: [],
denominations: [], denominations: [],
walletRootPub: bs.walletRootPub, wallet_root_pub: bs.walletRootPub,
}; };
// If the backup changed, we increment our clock. // If the backup changed, we increment our clock.

View File

@ -15,6 +15,8 @@
*/ */
/** /**
* Type declarations for the exchange's reserve transaction information.
*
* @author Florian Dold <dold@taler.net> * @author Florian Dold <dold@taler.net>
*/ */

File diff suppressed because it is too large Load Diff