Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /taker/stop endpoint to RPC #1137

Merged
merged 1 commit into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions jmclient/jmclient/wallet-rpc-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ create and broadcast a transaction (without coinjoin)
| ---- | ----------- |
| 200 | transaction broadcast OK. |
| 400 | Bad request format. |
| 404 | Item not found. |
| 401 | Unable to authorise the credentials that were supplied. |
| 409 | Transaction failed to broadcast. |

Expand Down Expand Up @@ -301,6 +302,7 @@ Start the yield generator service with the configuration settings specified in t
| 202 | The request has been submitted successfully for processing, but the processing has not been completed. |
| 400 | Bad request format. |
| 401 | Unable to authorise the credentials that were supplied. |
| 404 | Item not found. |
| 503 | The server is not ready to process the request. |

##### Security
Expand Down Expand Up @@ -333,6 +335,7 @@ stop the yield generator service
| 202 | The request has been submitted successfully for processing, but the processing has not been completed. |
| 400 | Bad request format. |
| 401 | Unable to authorise the credentials that were supplied. |
| 404 | Item not found. |

##### Security

Expand Down Expand Up @@ -374,6 +377,38 @@ initiate a coinjoin as taker
| --- | --- |
| bearerAuth | |

### /wallet/{walletname}/taker/stop

#### GET
##### Summary

stop a running coinjoin attempt

##### Description

stop a running coinjoin attempt

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| walletname | path | name of wallet including .jmdat | Yes | string |

##### Responses

| Code | Description |
| ---- | ----------- |
| 202 | The request has been submitted successfully for processing, but the processing has not been completed. |
| 400 | Bad request format. |
| 401 | Unable to authorise the credentials that were supplied. |
| 404 | Item not found. |

##### Security

| Security Schema | Scopes |
| --- | --- |
| bearerAuth | |

### /wallet/{walletname}/configset

#### POST
Expand Down
29 changes: 29 additions & 0 deletions jmclient/jmclient/wallet-rpc-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ paths:
$ref: '#/components/responses/400-BadRequest'
'401':
$ref: '#/components/responses/401-Unauthorized'
'404':
$ref: '#/components/responses/404-NotFound'
'409':
$ref: '#/components/responses/409-TransactionFailed'
/wallet/{walletname}/maker/start:
Expand Down Expand Up @@ -255,6 +257,8 @@ paths:
$ref: '#/components/responses/400-BadRequest'
'401':
$ref: '#/components/responses/401-Unauthorized'
'404':
$ref: '#/components/responses/404-NotFound'
'503':
$ref: '#/components/responses/503-ServiceUnavailable'
/wallet/{walletname}/maker/stop:
Expand All @@ -278,6 +282,8 @@ paths:
$ref: '#/components/responses/400-BadRequest'
'401':
$ref: "#/components/responses/401-Unauthorized"
'404':
$ref: '#/components/responses/404-NotFound'
/wallet/{walletname}/taker/coinjoin:
post:
security:
Expand Down Expand Up @@ -311,6 +317,29 @@ paths:
$ref: '#/components/responses/409-NoConfig'
'503':
$ref: '#/components/responses/503-ServiceUnavailable'
/wallet/{walletname}/taker/stop:
get:
security:
- bearerAuth: []
summary: stop a running coinjoin attempt
operationId: stopcoinjoin
description: stop a running coinjoin attempt
parameters:
- name: walletname
in: path
description: name of wallet including .jmdat
required: true
schema:
type: string
responses:
'202':
$ref: "#/components/responses/202-Accepted"
'400':
$ref: '#/components/responses/400-BadRequest'
'401':
$ref: "#/components/responses/401-Unauthorized"
'404':
$ref: '#/components/responses/404-NotFound'
/wallet/{walletname}/configset:
post:
security:
Expand Down
15 changes: 14 additions & 1 deletion jmclient/jmclient/wallet_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,21 @@ def listutxos(self, request, walletname):
utxos_response = self.get_listutxos_response(utxos)
return make_jmwalletd_response(request, utxos=utxos_response)

# route to abort a currently running coinjoin
@app.route('/wallet/<string:walletname>/taker/stop', methods=['GET'])
def stopcoinjoin(self, request, walletname):
self.check_cookie(request)
if not self.wallet_service:
raise NoWalletFound()
if not self.wallet_name == walletname:
raise InvalidRequestFormat()
if not self.coinjoin_state == CJ_TAKER_RUNNING:
raise ServiceNotStarted()
self.taker_finished(False)
return make_jmwalletd_response(request, status=202)

#route to start a coinjoin transaction
@app.route('/wallet/<string:walletname>/taker/coinjoin',methods=['POST'])
@app.route('/wallet/<string:walletname>/taker/coinjoin', methods=['POST'])
def docoinjoin(self, request, walletname):
self.check_cookie(request)
if not self.wallet_service:
Expand Down