aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/wallet/cryptoLib.ts1
-rw-r--r--lib/wallet/emscriptif.ts2
-rw-r--r--lib/wallet/types.ts3
-rw-r--r--lib/wallet/wallet.ts22
-rw-r--r--lib/wallet/wxMessaging.ts18
5 files changed, 46 insertions, 0 deletions
diff --git a/lib/wallet/cryptoLib.ts b/lib/wallet/cryptoLib.ts
index 769cb3356..967fc23c8 100644
--- a/lib/wallet/cryptoLib.ts
+++ b/lib/wallet/cryptoLib.ts
@@ -125,6 +125,7 @@ namespace RpcFunctions {
fee_deposit: (new native.Amount(denom.fee_deposit)).toNbo(),
fee_refresh: (new native.Amount(denom.fee_refresh)).toNbo(),
fee_withdraw: (new native.Amount(denom.fee_withdraw)).toNbo(),
+ fee_refund: (new native.Amount(denom.fee_refund)).toNbo(),
});
let nativeSig = new native.EddsaSignature();
diff --git a/lib/wallet/emscriptif.ts b/lib/wallet/emscriptif.ts
index b03bc9bc7..4ec029e52 100644
--- a/lib/wallet/emscriptif.ts
+++ b/lib/wallet/emscriptif.ts
@@ -866,6 +866,7 @@ export interface DenominationKeyValidityPS_args {
fee_withdraw: AmountNbo;
fee_deposit: AmountNbo;
fee_refresh: AmountNbo;
+ fee_refund: AmountNbo;
denom_hash: HashCode;
}
@@ -889,6 +890,7 @@ export class DenominationKeyValidityPS extends SignatureStruct {
["fee_withdraw", AmountNbo],
["fee_deposit", AmountNbo],
["fee_refresh", AmountNbo],
+ ["fee_refund", AmountNbo],
["denom_hash", HashCode]
];
}
diff --git a/lib/wallet/types.ts b/lib/wallet/types.ts
index 8aa03d82b..5045a5b9a 100644
--- a/lib/wallet/types.ts
+++ b/lib/wallet/types.ts
@@ -75,6 +75,9 @@ export class Denomination {
@Checkable.Value(AmountJson)
fee_refresh: AmountJson;
+ @Checkable.Value(AmountJson)
+ fee_refund: AmountJson;
+
@Checkable.String
stamp_start: string;
diff --git a/lib/wallet/wallet.ts b/lib/wallet/wallet.ts
index dde7a8248..3c9f3ffed 100644
--- a/lib/wallet/wallet.ts
+++ b/lib/wallet/wallet.ts
@@ -522,6 +522,28 @@ export class Wallet {
/**
+ * Add a contract to the wallet and sign coins,
+ * but do not send them yet.
+ */
+ checkPay(offer: Offer): Promise<any> {
+ console.log("executing checkPay");
+ return Promise.resolve().then(() => {
+ return this.getPossibleExchangeCoins(offer.contract.amount,
+ offer.contract.max_fee,
+ offer.contract.exchanges)
+ }).then((mcs) => {
+ if (Object.keys(mcs).length == 0) {
+ console.log("not confirming payment, insufficient coins");
+ return {
+ error: "coins-insufficient",
+ };
+ }
+ return {};
+ });
+ }
+
+
+ /**
* Retrieve all necessary information for looking up the contract
* with the given hash.
*/
diff --git a/lib/wallet/wxMessaging.ts b/lib/wallet/wxMessaging.ts
index 64b16de8d..164342f4e 100644
--- a/lib/wallet/wxMessaging.ts
+++ b/lib/wallet/wxMessaging.ts
@@ -99,6 +99,24 @@ function makeHandlers(db: IDBDatabase,
return wallet.confirmPay(offer);
},
+ ["check-pay"]: function(detail, sender) {
+ let offer;
+ try {
+ offer = Offer.checked(detail.offer);
+ } catch (e) {
+ if (e instanceof Checkable.SchemaError) {
+ console.error("schema error:", e.message);
+ return Promise.resolve({
+ error: "invalid contract",
+ hint: e.message,
+ detail: detail
+ });
+ } else {
+ throw e;
+ }
+ }
+ return wallet.checkPay(offer);
+ },
["execute-payment"]: function(detail, sender) {
return wallet.executePayment(detail.H_contract);
},