diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-01-17 05:33:06 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-01-17 05:33:06 +0100 |
commit | d4c2f6f6f992c36609c4a029afcb378a7f839ddf (patch) | |
tree | 2c50f9f1fa65ccea77894460b9d2080184914ab2 /src/wallet.ts | |
parent | c62ba4986fbfcb8637a3befadf3d3eddbd5348ca (diff) |
use full amount with wire fees when creating deposit permission
Diffstat (limited to 'src/wallet.ts')
-rw-r--r-- | src/wallet.ts | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/wallet.ts b/src/wallet.ts index 24fab9f86..91da5873b 100644 --- a/src/wallet.ts +++ b/src/wallet.ts @@ -593,15 +593,23 @@ export class Wallet { continue; } + console.log("payment coins: wireFeeLimit", wireFeeLimit); + console.log("payment coins: wireFeeAmortization", wireFeeAmortization); + console.log("payment coins: fees", fees); + console.log("payment coins: wireMethod", wireMethod); + console.log("payment coins: wireFeeTime", wireFeeTime); + let totalFees = Amounts.getZero(currency); let wireFee: AmountJson|undefined; for (const fee of (fees.feesForType[wireMethod] || [])) { - if (fee.startStamp >= wireFeeTime && fee.endStamp <= wireFeeTime) { + if (fee.startStamp <= wireFeeTime && fee.endStamp >= wireFeeTime) { wireFee = fee.wireFee; break; } } + console.log("payment coins: current wire fees", wireFee); + if (wireFee) { const amortizedWireFee = Amounts.divide(wireFee, wireFeeAmortization); if (Amounts.cmp(wireFeeLimit, amortizedWireFee) < 0) { @@ -616,6 +624,7 @@ export class Wallet { return { cds: res.cds, exchangeUrl: exchange.baseUrl, + totalAmount: remainingAmount, totalFees, }; } @@ -766,8 +775,8 @@ export class Wallet { const sd = await this.getSpeculativePayData(proposalId); if (!sd) { - const { exchangeUrl, cds } = res; - const payCoinInfo = await this.cryptoApi.signDeposit(proposal.contractTerms, cds); + const { exchangeUrl, cds, totalAmount } = res; + const payCoinInfo = await this.cryptoApi.signDeposit(proposal.contractTerms, cds, totalAmount); purchase = await this.recordConfirmPay(proposal, payCoinInfo, exchangeUrl); } else { purchase = await this.recordConfirmPay(sd.proposal, sd.payCoinInfo, sd.exchangeUrl); @@ -844,8 +853,8 @@ export class Wallet { // Only create speculative signature if we don't already have one for this proposal if ((!this.speculativePayData) || (this.speculativePayData && this.speculativePayData.proposalId !== proposalId)) { - const { exchangeUrl, cds } = res; - const payCoinInfo = await this.cryptoApi.signDeposit(proposal.contractTerms, cds); + const { exchangeUrl, cds, totalAmount } = res; + const payCoinInfo = await this.cryptoApi.signDeposit(proposal.contractTerms, cds, totalAmount); this.speculativePayData = { exchangeUrl, payCoinInfo, @@ -2456,7 +2465,7 @@ export class Wallet { const contractTermsHash = await this.cryptoApi.hashString(canonicalJson(contractTerms)); - const payCoinInfo = await this.cryptoApi.signDeposit(contractTerms, cds); + const payCoinInfo = await this.cryptoApi.signDeposit(contractTerms, cds, contractTerms.amount); console.log("pci", payCoinInfo); |