aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-15 21:40:06 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-15 21:40:06 +0100
commit1b9c5855a8afb6833ff7a706f5bed5650e1191ad (patch)
treed880c4418fe337ac7dd362466b80edf94296b58e /src/crypto
parent59bd755f7d6a3451859ca08084df83d465cd8500 (diff)
simplify /pay, add pay event
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/workers/cryptoApi.ts6
-rw-r--r--src/crypto/workers/cryptoImplementation.ts22
2 files changed, 14 insertions, 14 deletions
diff --git a/src/crypto/workers/cryptoApi.ts b/src/crypto/workers/cryptoApi.ts
index 3c6758670..da807cce0 100644
--- a/src/crypto/workers/cryptoApi.ts
+++ b/src/crypto/workers/cryptoApi.ts
@@ -39,7 +39,7 @@ import { ContractTerms, PaybackRequest } from "../../types/talerTypes";
import {
BenchmarkResult,
CoinWithDenom,
- PayCoinInfo,
+ PaySigInfo,
PlanchetCreationResult,
PlanchetCreationRequest,
} from "../../types/walletTypes";
@@ -387,8 +387,8 @@ export class CryptoApi {
contractTerms: ContractTerms,
cds: CoinWithDenom[],
totalAmount: AmountJson,
- ): Promise<PayCoinInfo> {
- return this.doRpc<PayCoinInfo>(
+ ): Promise<PaySigInfo> {
+ return this.doRpc<PaySigInfo>(
"signDeposit",
3,
contractTerms,
diff --git a/src/crypto/workers/cryptoImplementation.ts b/src/crypto/workers/cryptoImplementation.ts
index 01cd797b9..0049a1222 100644
--- a/src/crypto/workers/cryptoImplementation.ts
+++ b/src/crypto/workers/cryptoImplementation.ts
@@ -39,11 +39,12 @@ import { CoinPaySig, ContractTerms, PaybackRequest } from "../../types/talerType
import {
BenchmarkResult,
CoinWithDenom,
- PayCoinInfo,
+ PaySigInfo,
Timestamp,
PlanchetCreationResult,
PlanchetCreationRequest,
getTimestampNow,
+ CoinPayInfo,
} from "../../types/walletTypes";
import { canonicalJson, getTalerStampSec } from "../../util/helpers";
import { AmountJson } from "../../util/amounts";
@@ -348,11 +349,9 @@ export class CryptoImplementation {
contractTerms: ContractTerms,
cds: CoinWithDenom[],
totalAmount: AmountJson,
- ): PayCoinInfo {
- const ret: PayCoinInfo = {
- originalCoins: [],
- sigs: [],
- updatedCoins: [],
+ ): PaySigInfo {
+ const ret: PaySigInfo = {
+ coinInfo: [],
};
const contractTermsHash = this.hashString(canonicalJson(contractTerms));
@@ -369,8 +368,6 @@ export class CryptoImplementation {
let amountRemaining = total;
for (const cd of cds) {
- const originalCoin = { ...cd.coin };
-
if (amountRemaining.value === 0 && amountRemaining.fraction === 0) {
break;
}
@@ -416,9 +413,12 @@ export class CryptoImplementation {
exchange_url: cd.denom.exchangeBaseUrl,
ub_sig: cd.coin.denomSig,
};
- ret.sigs.push(s);
- ret.updatedCoins.push(cd.coin);
- ret.originalCoins.push(originalCoin);
+ const coinInfo: CoinPayInfo = {
+ sig: s,
+ coinPub: cd.coin.coinPub,
+ subtractedAmount: coinSpend,
+ };
+ ret.coinInfo.push(coinInfo);
}
return ret;
}