aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-12 21:54:14 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-12 21:54:14 +0100
commitca2a46a8575d66d529accb1ce3aaf97be8f37e2f (patch)
treec05c3452c2dfe81713cf36ce06d205faa6bfb0fa /src/crypto
parent659435570440c5a5eacde3a2e6ef5b3f3430a45f (diff)
precompute speculative signature for payment
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/cryptoApi.ts4
-rw-r--r--src/crypto/cryptoWorker.ts11
2 files changed, 11 insertions, 4 deletions
diff --git a/src/crypto/cryptoApi.ts b/src/crypto/cryptoApi.ts
index 94083d622..d0ba6ada8 100644
--- a/src/crypto/cryptoApi.ts
+++ b/src/crypto/cryptoApi.ts
@@ -275,8 +275,8 @@ export class CryptoApi {
return this.doRpc<boolean>("isValidWireFee", 2, type, wf, masterPub);
}
- isValidPaymentSignature(sig: string, contractHash: string, merchantPub: string) {
- return this.doRpc<PayCoinInfo>("isValidPaymentSignature", 1, sig, contractHash, merchantPub);
+ isValidPaymentSignature(sig: string, contractHash: string, merchantPub: string): Promise<boolean> {
+ return this.doRpc<boolean>("isValidPaymentSignature", 1, sig, contractHash, merchantPub);
}
signDeposit(contractTerms: ContractTerms,
diff --git a/src/crypto/cryptoWorker.ts b/src/crypto/cryptoWorker.ts
index 92947d039..28634b234 100644
--- a/src/crypto/cryptoWorker.ts
+++ b/src/crypto/cryptoWorker.ts
@@ -261,7 +261,11 @@ namespace RpcFunctions {
*/
export function signDeposit(contractTerms: ContractTerms,
cds: CoinWithDenom[]): PayCoinInfo {
- const ret: PayCoinInfo = [];
+ const ret: PayCoinInfo = {
+ originalCoins: [],
+ updatedCoins: [],
+ sigs: [],
+ };
const contractTermsHash = hashString(canonicalJson(contractTerms));
@@ -275,6 +279,7 @@ namespace RpcFunctions {
const amountRemaining = new native.Amount(total);
for (const cd of cds) {
let coinSpend: Amount;
+ const originalCoin = { ...(cd.coin) };
if (amountRemaining.value === 0 && amountRemaining.fraction === 0) {
break;
@@ -324,7 +329,9 @@ namespace RpcFunctions {
f: coinSpend.toJson(),
ub_sig: cd.coin.denomSig,
};
- ret.push({sig: s, updatedCoin: cd.coin});
+ ret.sigs.push(s);
+ ret.updatedCoins.push(cd.coin);
+ ret.originalCoins.push(originalCoin);
}
return ret;
}