aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts6
-rw-r--r--packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts6
-rw-r--r--packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts10
-rw-r--r--packages/taler-wallet-cli/src/index.ts89
-rw-r--r--packages/taler-wallet-core/src/wallet-api-types.ts126
-rw-r--r--packages/taler-wallet-core/src/wallet.ts14
6 files changed, 141 insertions, 110 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts b/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts
index 1d8986436..524d04c94 100644
--- a/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts
+++ b/packages/taler-harness/src/integrationtests/test-age-restrictions-peer.ts
@@ -71,7 +71,7 @@ export async function runAgeRestrictionsPeerTest(t: GlobalTestState) {
);
const initResp = await wallet.client.call(
- WalletApiOperation.InitiatePeerPushPayment,
+ WalletApiOperation.InitiatePeerPushDebit,
{
partialContractTerms: {
summary: "Hello, World",
@@ -84,13 +84,13 @@ export async function runAgeRestrictionsPeerTest(t: GlobalTestState) {
await wallet.runUntilDone();
const checkResp = await walletTwo.client.call(
- WalletApiOperation.CheckPeerPushPayment,
+ WalletApiOperation.PreparePeerPushCredit,
{
talerUri: initResp.talerUri,
},
);
- await walletTwo.client.call(WalletApiOperation.AcceptPeerPushPayment, {
+ await walletTwo.client.call(WalletApiOperation.ConfirmPeerPushCredit, {
peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId,
});
diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
index 15b274e6b..0bab14578 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
@@ -53,7 +53,7 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) {
);
const resp = await wallet1.client.call(
- WalletApiOperation.InitiatePeerPullPayment,
+ WalletApiOperation.InitiatePeerPullCredit,
{
exchangeBaseUrl: exchange.baseUrl,
partialContractTerms: {
@@ -69,7 +69,7 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) {
await wallet1.runPending();
const checkResp = await wallet2.client.call(
- WalletApiOperation.CheckPeerPullPayment,
+ WalletApiOperation.PreparePeerPullDebit,
{
talerUri: resp.talerUri,
},
@@ -78,7 +78,7 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) {
console.log(`checkResp: ${j2s(checkResp)}`);
const acceptResp = await wallet2.client.call(
- WalletApiOperation.AcceptPeerPullPayment,
+ WalletApiOperation.ConfirmPeerPullDebit,
{
peerPullPaymentIncomingId: checkResp.peerPullPaymentIncomingId,
},
diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
index 39d9b9edb..60ccce000 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
@@ -56,7 +56,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
{
const resp = await wallet1.client.call(
- WalletApiOperation.InitiatePeerPushPayment,
+ WalletApiOperation.InitiatePeerPushDebit,
{
partialContractTerms: {
summary: "Hello World 😁😇",
@@ -69,7 +69,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
console.log(resp);
}
const resp = await wallet1.client.call(
- WalletApiOperation.InitiatePeerPushPayment,
+ WalletApiOperation.InitiatePeerPushDebit,
{
partialContractTerms: {
summary: "Hello World 🥺",
@@ -82,7 +82,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
console.log(resp);
const checkResp = await wallet2.client.call(
- WalletApiOperation.CheckPeerPushPayment,
+ WalletApiOperation.PreparePeerPushCredit,
{
talerUri: resp.talerUri,
},
@@ -91,7 +91,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
console.log(checkResp);
const acceptResp = await wallet2.client.call(
- WalletApiOperation.AcceptPeerPushPayment,
+ WalletApiOperation.ConfirmPeerPushCredit,
{
peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId,
},
@@ -115,7 +115,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
console.log(`txn2: ${j2s(txn2)}`);
const ex1 = await t.assertThrowsTalerErrorAsync(async () => {
- await wallet1.client.call(WalletApiOperation.InitiatePeerPushPayment, {
+ await wallet1.client.call(WalletApiOperation.InitiatePeerPushDebit, {
partialContractTerms: {
summary: "(this will fail)",
amount: "TESTKUDOS:15",
diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts
index dbd5ce956..d6d780576 100644
--- a/packages/taler-wallet-cli/src/index.ts
+++ b/packages/taler-wallet-cli/src/index.ts
@@ -925,13 +925,32 @@ depositCli
});
});
-const advancedCli = walletCli.subcommand("advancedArgs", "advanced", {
- help: "Subcommands for advanced operations (only use if you know what you're doing!).",
+const peerCli = walletCli.subcommand("peerArgs", "p2p", {
+ help: "Subcommands for peer-to-peer payments.",
});
-advancedCli
- .subcommand("checkPayPull", "check-pay-pull", {
- help: "Check fees for a peer-pull payment initiation.",
+peerCli
+ .subcommand("checkPayPush", "check-push-debit", {
+ help: "Check fees for starting a peer-push debit transaction.",
+ })
+ .requiredArgument("amount", clk.STRING, {
+ help: "Amount to pay",
+ })
+ .action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const resp = await wallet.client.call(
+ WalletApiOperation.CheckPeerPushDebit,
+ {
+ amount: args.checkPayPush.amount,
+ },
+ );
+ console.log(JSON.stringify(resp, undefined, 2));
+ });
+ });
+
+peerCli
+ .subcommand("checkPayPull", "check-pull-credit", {
+ help: "Check fees for a starting peer-pull credit transaction.",
})
.requiredArgument("amount", clk.STRING, {
help: "Amount to request",
@@ -939,7 +958,7 @@ advancedCli
.action(async (args) => {
await withWallet(args, async (wallet) => {
const resp = await wallet.client.call(
- WalletApiOperation.PreparePeerPullPayment,
+ WalletApiOperation.CheckPeerPullCredit,
{
amount: args.checkPayPull.amount,
},
@@ -948,13 +967,13 @@ advancedCli
});
});
-advancedCli
- .subcommand("prepareIncomingPayPull", "prepare-incoming-pay-pull")
+peerCli
+ .subcommand("prepareIncomingPayPull", "prepare-pull-debit")
.requiredArgument("talerUri", clk.STRING)
.action(async (args) => {
await withWallet(args, async (wallet) => {
const resp = await wallet.client.call(
- WalletApiOperation.CheckPeerPullPayment,
+ WalletApiOperation.PreparePeerPullDebit,
{
talerUri: args.prepareIncomingPayPull.talerUri,
},
@@ -963,13 +982,13 @@ advancedCli
});
});
-advancedCli
- .subcommand("confirmIncomingPayPull", "confirm-incoming-pay-pull")
+peerCli
+ .subcommand("confirmIncomingPayPull", "confirm-pull-debit")
.requiredArgument("peerPullPaymentIncomingId", clk.STRING)
.action(async (args) => {
await withWallet(args, async (wallet) => {
const resp = await wallet.client.call(
- WalletApiOperation.AcceptPeerPullPayment,
+ WalletApiOperation.ConfirmPeerPullDebit,
{
peerPullPaymentIncomingId:
args.confirmIncomingPayPull.peerPullPaymentIncomingId,
@@ -979,8 +998,24 @@ advancedCli
});
});
-advancedCli
- .subcommand("initiatePayPull", "initiate-pay-pull", {
+peerCli
+ .subcommand("confirmIncomingPayPush", "confirm-push-credit")
+ .requiredArgument("peerPushPaymentIncomingId", clk.STRING)
+ .action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const resp = await wallet.client.call(
+ WalletApiOperation.ConfirmPeerPushCredit,
+ {
+ peerPushPaymentIncomingId:
+ args.confirmIncomingPayPush.peerPushPaymentIncomingId,
+ },
+ );
+ console.log(JSON.stringify(resp, undefined, 2));
+ });
+ });
+
+peerCli
+ .subcommand("initiatePayPull", "initiate-pull-credit", {
help: "Initiate a peer-pull payment.",
})
.requiredArgument("amount", clk.STRING, {
@@ -993,7 +1028,7 @@ advancedCli
.action(async (args) => {
await withWallet(args, async (wallet) => {
const resp = await wallet.client.call(
- WalletApiOperation.InitiatePeerPullPayment,
+ WalletApiOperation.InitiatePeerPullCredit,
{
exchangeBaseUrl: args.initiatePayPull.exchangeBaseUrl,
partialContractTerms: {
@@ -1013,27 +1048,23 @@ advancedCli
});
});
-advancedCli
- .subcommand("checkPayPush", "check-pay-push", {
- help: "Check fees for a peer-push payment.",
- })
- .requiredArgument("amount", clk.STRING, {
- help: "Amount to pay",
- })
+peerCli
+ .subcommand("preparePushCredit", "prepare-push-credit")
+ .requiredArgument("talerUri", clk.STRING)
.action(async (args) => {
await withWallet(args, async (wallet) => {
const resp = await wallet.client.call(
- WalletApiOperation.PreparePeerPushPayment,
+ WalletApiOperation.PreparePeerPushCredit,
{
- amount: args.checkPayPush.amount,
+ talerUri: args.preparePushCredit.talerUri,
},
);
console.log(JSON.stringify(resp, undefined, 2));
});
});
-advancedCli
- .subcommand("payPush", "initiate-pay-push", {
+peerCli
+ .subcommand("payPush", "initiate-push-debit", {
help: "Initiate a peer-push payment.",
})
.requiredArgument("amount", clk.STRING, {
@@ -1045,7 +1076,7 @@ advancedCli
.action(async (args) => {
await withWallet(args, async (wallet) => {
const resp = await wallet.client.call(
- WalletApiOperation.InitiatePeerPushPayment,
+ WalletApiOperation.InitiatePeerPushDebit,
{
partialContractTerms: {
amount: args.payPush.amount,
@@ -1064,6 +1095,10 @@ advancedCli
});
});
+const advancedCli = walletCli.subcommand("advancedArgs", "advanced", {
+ help: "Subcommands for advanced operations (only use if you know what you're doing!).",
+});
+
advancedCli
.subcommand("serve", "serve", {
help: "Serve the wallet API via a unix domain socket.",
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts
index 093a1b15c..f1d1441d6 100644
--- a/packages/taler-wallet-core/src/wallet-api-types.ts
+++ b/packages/taler-wallet-core/src/wallet-api-types.ts
@@ -29,8 +29,8 @@ import {
AcceptExchangeTosRequest,
AcceptManualWithdrawalRequest,
AcceptManualWithdrawalResult,
- AcceptPeerPullPaymentRequest,
- AcceptPeerPushPaymentRequest,
+ AcceptPeerPullPaymentRequest as ConfirmPeerPullDebitRequest,
+ AcceptPeerPushPaymentRequest as ConfirmPeerPushCreditRequest,
AcceptTipRequest,
AcceptTipResponse,
AcceptWithdrawalResponse,
@@ -42,8 +42,8 @@ import {
ApplyRefundResponse,
BackupRecovery,
BalancesResponse,
- CheckPeerPullPaymentRequest,
- CheckPeerPullPaymentResponse,
+ CheckPeerPullPaymentRequest as PreparePeerPullDebitRequest,
+ CheckPeerPullPaymentResponse as PreparePeerPullDebitResponse,
CheckPeerPushPaymentRequest,
CheckPeerPushPaymentResponse,
CoinDumpJson,
@@ -64,8 +64,8 @@ import {
GetFeeForDepositRequest,
GetWithdrawalDetailsForAmountRequest,
GetWithdrawalDetailsForUriRequest,
- InitiatePeerPullPaymentRequest,
- InitiatePeerPullPaymentResponse,
+ InitiatePeerPullPaymentRequest as InitiatePeerPullCreditRequest,
+ InitiatePeerPullPaymentResponse as InitiatePeerPullCreditResponse,
InitiatePeerPushPaymentRequest,
InitiatePeerPushPaymentResponse,
InitRequest,
@@ -79,10 +79,10 @@ import {
PreparePayRequest,
PreparePayResult,
PreparePayTemplateRequest,
- PreparePeerPullPaymentRequest,
- PreparePeerPullPaymentResponse,
- PreparePeerPushPaymentRequest,
- PreparePeerPushPaymentResponse,
+ PreparePeerPullPaymentRequest as CheckPeerPullCreditRequest,
+ PreparePeerPullPaymentResponse as CheckPeerPullCreditResponse,
+ PreparePeerPushPaymentRequest as CheckPeerPushDebitRequest,
+ PreparePeerPushPaymentResponse as CheckPeerPushDebitResponse,
PrepareRefundRequest,
PrepareRefundResult,
PrepareTipRequest,
@@ -183,14 +183,22 @@ export enum WalletApiOperation {
WithdrawFakebank = "withdrawFakebank",
ImportDb = "importDb",
ExportDb = "exportDb",
- PreparePeerPushPayment = "preparePeerPushPayment",
- InitiatePeerPushPayment = "initiatePeerPushPayment",
- CheckPeerPushPayment = "checkPeerPushPayment",
- AcceptPeerPushPayment = "acceptPeerPushPayment",
- PreparePeerPullPayment = "preparePeerPullPayment",
- InitiatePeerPullPayment = "initiatePeerPullPayment",
- CheckPeerPullPayment = "checkPeerPullPayment",
- AcceptPeerPullPayment = "acceptPeerPullPayment",
+ // FIXME: Also rename enum value
+ CheckPeerPushDebit = "preparePeerPushPayment",
+ // FIXME: Also rename enum value
+ InitiatePeerPushDebit = "initiatePeerPushPayment",
+ // FIXME: Also rename enum value
+ PreparePeerPushCredit = "checkPeerPushPayment",
+ // FIXME: Also rename enum value
+ ConfirmPeerPushCredit = "acceptPeerPushPayment",
+ // FIXME: Also rename enum value
+ CheckPeerPullCredit = "preparePeerPullPayment",
+ // FIXME: Also rename enum value
+ InitiatePeerPullCredit = "initiatePeerPullPayment",
+ // FIXME: Also rename enum value
+ PreparePeerPullDebit = "checkPeerPullPayment",
+ // FIXME: Also rename enum value
+ ConfirmPeerPullDebit = "acceptPeerPullPayment",
ClearDb = "clearDb",
Recycle = "recycle",
SetDevMode = "setDevMode",
@@ -593,85 +601,73 @@ export type ExportBackupPlainOp = {
/**
* Check if initiating a peer push payment is possible
* based on the funds in the wallet.
- *
- * FIXME: Rename to CheckPeerPushPaymentInitiation
*/
-export type PreparePeerPushPaymentOp = {
- op: WalletApiOperation.PreparePeerPushPayment;
- request: PreparePeerPushPaymentRequest;
- response: PreparePeerPushPaymentResponse;
+export type CheckPeerPushDebitOp = {
+ op: WalletApiOperation.CheckPeerPushDebit;
+ request: CheckPeerPushDebitRequest;
+ response: CheckPeerPushDebitResponse;
};
/**
* Initiate an outgoing peer push payment.
*/
-export type InitiatePeerPushPaymentOp = {
- op: WalletApiOperation.InitiatePeerPushPayment;
+export type InitiatePeerPushDebitOp = {
+ op: WalletApiOperation.InitiatePeerPushDebit;
request: InitiatePeerPushPaymentRequest;
response: InitiatePeerPushPaymentResponse;
};
/**
* Check an incoming peer push payment.
- *
- * FIXME: Rename to "PrepareIncomingPeerPushPayment"
*/
-export type CheckPeerPushPaymentOp = {
- op: WalletApiOperation.CheckPeerPushPayment;
+export type PreparePeerPushCreditOp = {
+ op: WalletApiOperation.PreparePeerPushCredit;
request: CheckPeerPushPaymentRequest;
response: CheckPeerPushPaymentResponse;
};
/**
* Accept an incoming peer push payment.
- *
- * FIXME: Rename to ConfirmIncomingPeerPushPayment
*/
-export type AcceptPeerPushPaymentOp = {
- op: WalletApiOperation.AcceptPeerPushPayment;
- request: AcceptPeerPushPaymentRequest;
+export type ConfirmPeerPushCreditOp = {
+ op: WalletApiOperation.ConfirmPeerPushCredit;
+ request: ConfirmPeerPushCreditRequest;
response: EmptyObject;
};
/**
- * Initiate an outgoing peer pull payment.
- *
- * FIXME: This does not check anything, so rename to CheckPeerPullPaymentInitiation
+ * Check fees for an outgoing peer pull payment.
*/
-export type PreparePeerPullPaymentOp = {
- op: WalletApiOperation.PreparePeerPullPayment;
- request: PreparePeerPullPaymentRequest;
- response: PreparePeerPullPaymentResponse;
+export type CheckPeerPullCreditOp = {
+ op: WalletApiOperation.CheckPeerPullCredit;
+ request: CheckPeerPullCreditRequest;
+ response: CheckPeerPullCreditResponse;
};
/**
* Initiate an outgoing peer pull payment.
*/
-export type InitiatePeerPullPaymentOp = {
- op: WalletApiOperation.InitiatePeerPullPayment;
- request: InitiatePeerPullPaymentRequest;
- response: InitiatePeerPullPaymentResponse;
+export type InitiatePeerPullCreditOp = {
+ op: WalletApiOperation.InitiatePeerPullCredit;
+ request: InitiatePeerPullCreditRequest;
+ response: InitiatePeerPullCreditResponse;
};
/**
* Prepare for an incoming peer pull payment.
- *
- * FIXME: Rename to "PrepareIncomingPeerPullPayment"
*/
-export type CheckPeerPullPaymentOp = {
- op: WalletApiOperation.CheckPeerPullPayment;
- request: CheckPeerPullPaymentRequest;
- response: CheckPeerPullPaymentResponse;
+export type PreparePeerPullDebitOp = {
+ op: WalletApiOperation.PreparePeerPullDebit;
+ request: PreparePeerPullDebitRequest;
+ response: PreparePeerPullDebitResponse;
};
/**
* Accept an incoming peer pull payment (i.e. pay the other party).
- *
- * FIXME: Rename to ConfirmIncomingPeerPullPayment
*/
-export type AcceptPeerPullPaymentOp = {
- op: WalletApiOperation.AcceptPeerPullPayment;
- request: AcceptPeerPullPaymentRequest;
+export type ConfirmPeerPullDebitOp = {
+ op: WalletApiOperation.ConfirmPeerPullDebit;
+ request: ConfirmPeerPullDebitRequest;
response: EmptyObject;
};
@@ -915,14 +911,14 @@ export type WalletOperations = {
[WalletApiOperation.TestPay]: TestPayOp;
[WalletApiOperation.ExportDb]: ExportDbOp;
[WalletApiOperation.ImportDb]: ImportDbOp;
- [WalletApiOperation.PreparePeerPushPayment]: PreparePeerPushPaymentOp;
- [WalletApiOperation.InitiatePeerPushPayment]: InitiatePeerPushPaymentOp;
- [WalletApiOperation.CheckPeerPushPayment]: CheckPeerPushPaymentOp;
- [WalletApiOperation.AcceptPeerPushPayment]: AcceptPeerPushPaymentOp;
- [WalletApiOperation.PreparePeerPullPayment]: PreparePeerPullPaymentOp;
- [WalletApiOperation.InitiatePeerPullPayment]: InitiatePeerPullPaymentOp;
- [WalletApiOperation.CheckPeerPullPayment]: CheckPeerPullPaymentOp;
- [WalletApiOperation.AcceptPeerPullPayment]: AcceptPeerPullPaymentOp;
+ [WalletApiOperation.CheckPeerPushDebit]: CheckPeerPushDebitOp;
+ [WalletApiOperation.InitiatePeerPushDebit]: InitiatePeerPushDebitOp;
+ [WalletApiOperation.PreparePeerPushCredit]: PreparePeerPushCreditOp;
+ [WalletApiOperation.ConfirmPeerPushCredit]: ConfirmPeerPushCreditOp;
+ [WalletApiOperation.CheckPeerPullCredit]: CheckPeerPullCreditOp;
+ [WalletApiOperation.InitiatePeerPullCredit]: InitiatePeerPullCreditOp;
+ [WalletApiOperation.PreparePeerPullDebit]: PreparePeerPullDebitOp;
+ [WalletApiOperation.ConfirmPeerPullDebit]: ConfirmPeerPullDebitOp;
[WalletApiOperation.ClearDb]: ClearDbOp;
[WalletApiOperation.Recycle]: RecycleOp;
[WalletApiOperation.ApplyDevExperiment]: ApplyDevExperimentOp;
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index e3a34f0da..ade6493e1 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -1432,31 +1432,31 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
const req = codecForPreparePeerPushPaymentRequest().decode(payload);
return await preparePeerPushPayment(ws, req);
}
- case WalletApiOperation.InitiatePeerPushPayment: {
+ case WalletApiOperation.InitiatePeerPushDebit: {
const req = codecForInitiatePeerPushPaymentRequest().decode(payload);
return await initiatePeerPushPayment(ws, req);
}
- case WalletApiOperation.CheckPeerPushPayment: {
+ case WalletApiOperation.PreparePeerPushCredit: {
const req = codecForCheckPeerPushPaymentRequest().decode(payload);
return await preparePeerPushCredit(ws, req);
}
- case WalletApiOperation.AcceptPeerPushPayment: {
+ case WalletApiOperation.ConfirmPeerPushCredit: {
const req = codecForAcceptPeerPushPaymentRequest().decode(payload);
return await acceptPeerPushPayment(ws, req);
}
- case WalletApiOperation.PreparePeerPullPayment: {
+ case WalletApiOperation.CheckPeerPullCredit: {
const req = codecForPreparePeerPullPaymentRequest().decode(payload);
return await checkPeerPullPaymentInitiation(ws, req);
}
- case WalletApiOperation.InitiatePeerPullPayment: {
+ case WalletApiOperation.InitiatePeerPullCredit: {
const req = codecForInitiatePeerPullPaymentRequest().decode(payload);
return await initiatePeerPullPayment(ws, req);
}
- case WalletApiOperation.CheckPeerPullPayment: {
+ case WalletApiOperation.PreparePeerPullDebit: {
const req = codecForCheckPeerPullPaymentRequest().decode(payload);
return await preparePeerPullCredit(ws, req);
}
- case WalletApiOperation.AcceptPeerPullPayment: {
+ case WalletApiOperation.ConfirmPeerPullDebit: {
const req = codecForAcceptPeerPullPaymentRequest().decode(payload);
return await acceptIncomingPeerPullPayment(ws, req);
}