fix /pay API
This commit is contained in:
parent
202d51c6a2
commit
09c7be80fd
@ -336,6 +336,7 @@ namespace RpcFunctions {
|
|||||||
coin_sig: coinSig,
|
coin_sig: coinSig,
|
||||||
contribution: coinSpend.toJson(),
|
contribution: coinSpend.toJson(),
|
||||||
denom_pub: cd.coin.denomPub,
|
denom_pub: cd.coin.denomPub,
|
||||||
|
exchange_url: cd.denom.exchangeBaseUrl,
|
||||||
ub_sig: cd.coin.denomSig,
|
ub_sig: cd.coin.denomSig,
|
||||||
};
|
};
|
||||||
ret.sigs.push(s);
|
ret.sigs.push(s);
|
||||||
|
@ -264,6 +264,11 @@ export interface CoinPaySig {
|
|||||||
* The amount that is subtracted from this coin with this payment.
|
* The amount that is subtracted from this coin with this payment.
|
||||||
*/
|
*/
|
||||||
contribution: AmountJson;
|
contribution: AmountJson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL of the exchange this coin was withdrawn from.
|
||||||
|
*/
|
||||||
|
exchange_url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -461,9 +466,9 @@ export interface PayReq {
|
|||||||
order_id: string;
|
order_id: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchange that the coins are from (base URL).
|
* Mode for /pay (pay or refund)
|
||||||
*/
|
*/
|
||||||
exchange: string;
|
mode: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -629,8 +629,8 @@ export class Wallet {
|
|||||||
chosenExchange: string): Promise<void> {
|
chosenExchange: string): Promise<void> {
|
||||||
const payReq: PayReq = {
|
const payReq: PayReq = {
|
||||||
coins: payCoinInfo.sigs,
|
coins: payCoinInfo.sigs,
|
||||||
exchange: chosenExchange,
|
|
||||||
merchant_pub: proposal.contractTerms.merchant_pub,
|
merchant_pub: proposal.contractTerms.merchant_pub,
|
||||||
|
mode: "pay",
|
||||||
order_id: proposal.contractTerms.order_id,
|
order_id: proposal.contractTerms.order_id,
|
||||||
};
|
};
|
||||||
const t: PurchaseRecord = {
|
const t: PurchaseRecord = {
|
||||||
@ -1693,7 +1693,9 @@ export class Wallet {
|
|||||||
if (t.finished) {
|
if (t.finished) {
|
||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
addTo(balance, "pendingIncoming", t.contractTerms.amount, t.payReq.exchange);
|
for (const c of t.payReq.coins) {
|
||||||
|
addTo(balance, "pendingIncoming", c.contribution, c.exchange_url);
|
||||||
|
}
|
||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2526,7 +2528,9 @@ export class Wallet {
|
|||||||
for (const pk of pendingKeys) {
|
for (const pk of pendingKeys) {
|
||||||
const perm = purchase.refundsPending[pk];
|
const perm = purchase.refundsPending[pk];
|
||||||
console.log("sending refund permission", perm);
|
console.log("sending refund permission", perm);
|
||||||
const reqUrl = (new URI("refund")).absoluteTo(purchase.payReq.exchange);
|
// FIXME: not correct once we support multiple exchanges per payment
|
||||||
|
const exchangeUrl = purchase.payReq.coins[0].exchange_url;
|
||||||
|
const reqUrl = (new URI("refund")).absoluteTo(exchangeUrl);
|
||||||
const resp = await this.http.postJson(reqUrl.href(), perm);
|
const resp = await this.http.postJson(reqUrl.href(), perm);
|
||||||
if (resp.status !== 200) {
|
if (resp.status !== 200) {
|
||||||
console.error("refund failed", resp);
|
console.error("refund failed", resp);
|
||||||
|
Loading…
Reference in New Issue
Block a user