Approve a received pledge
Basic Description
This endpoint is used to accept a pledge action in Taurus-NETWORK. An pledge may be done to any participant of Taurus-NETWORK, so long as the addresses have been shared.
This endpoint would accept a POST request with a JSON payload containing details of the pledge action to be approved. The signature
, comment
, ids
are the only required parameters that must be included within the JSON payload.
Prerequisites
Required Roles
Certain API endpoints require that the user has a specific role in order to access them. Roles are used to restrict access to certain functionality within the system and ensure that only authorized users are able to perform specific actions.
Here is the list of required Roles for this particular endpoint:
- TPUser
- Request Approver
To find out more about roles, please refer to the following page in the Taurus User Guides.
Required Input Parameters
Certain API endpoints require specific input parameters. Here is the list of Required Input Parameters for this particular endpoint:
- ids: the id or ids of the pledge action(s) to be approved.
- signature: the computed ECDSA signature for one or more pledge action IDs, encoded in Base64.
- comment: A comment as part of the approval.
Preconditions
It is important to note the correct ECDSA Signature needs to have been properly generated and the relevant Pledge Action Request(s) need to pre-exist on the system for the approval process to go through successfully.
ECDSA Signature
An ECDSA signature allows a user to publish a public key and then create a signature of some data with their private key, such that anyone can verify that the signature was created by the owner of this public key. To find out more about the computation and encoding of the appropriate ECDSA signature, please refer to the following page.
Signature Example
You can find a basic example in Bash on how to generate an ECDSA Signature.
export METADATAHASH='2d449c5e55515e76d862b8de2be2b62c6505ac968011efc36641594301a9c0ac'
output=$(echo -n '["$METADATAHASH"]' | openssl dgst -sha256 -sign [email protected] | openssl asn1parse -inform DER )
# output = 0:d=0 hl=2 l= 70 cons: SEQUENCE
# 2:d=1 hl=2 l= 33 prim: INTEGER :9F51A2A2049DBF22F281478337F6D6EA4D7987C40A2F256DF0965164D0D640FB
# 37:d=1 hl=2 l= 33 prim: INTEGER :FA037EA62EE530F558A79025AF006C46E087AFAB30F9CE61D43AF3C3C0505A67
num1=$(echo "$output" | cut -d: -f3 | cut -c0-64 ) # 9F51A2A2049DBF22F281478337F6D6EA4D7987C40A2F256DF0965164D0D640FB
num2=$(echo "$output" | cut -d: -f4 | cut -c1-65) # FA037EA62EE530F558A79025AF006C46E087AFAB30F9CE61D43AF3C3C0505A6
# concatenate the 2 outputs above
newoutput="$num1$num2" #9F51A2A2049DBF22F281478337F6D6EA4D7987C40A2F256DF0965164D0D640FBFA037EA62EE530F558A79025AF006C46E087AFAB30F9CE61D43AF3C3C0505A67
echo -n "$newoutput" | xxd -p -r | base64 | tr -d '\n'
# ECDSA Signature: CunRoDLkcCLjSoraqYBryk8KmnstFBrvrMxX5qZQFiQOiNdt+f96BJ6ChVKN/6YmVCvfrcRPPXpY/y8J7NYuNA==
Signature Result
A successful final output of the above script might look like this:
CunRoDLkcCLjSoraqYBryk8KmnstFBrvrMxX5qZQFiQOiNdt+f96BJ6ChVKN/6YmVCvfrcRPPXpY/y8J7NYuNA==
This result is what you eventually need to add within the JSON Body of the below Request.
Call Example
You can find a basic example in cURL below.
Please note that you will need to update the BASEURL
and the APITOKEN
for the command to function.
export BASEURL=https://taurus-protect-instance.com
export APIToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZXh0ZXJuYWxVc2VySUQiOiJ0ZWFtMUV4dGVybmFsVXNlcklEIiwidGVuYW50SUQiOjEsImNhcGl0YWxUZW5hbnRJRCI6MSwiZmlyc3RuYW1lIjoiSm9obiIsImxhc3RuYW1lIjoiRG9lIiwicm9sZXMiOlsidHB1c2VyIl0sImVtYWlsIjoidGVhbTFAYmFuay5jb20iLCJ1c2VybmFtZSI6InRlYW0xIiwiand0X3JlbmV3YWJsZV9hbW91bnQiOjAsImlzX3RvdHBfZW5hYmxlZCI6ZmFsc2UsImF1dGhfc3RhdHVzIjoiU1VDQ0VTUyIsImxhc3RfbG9naW4iOiIyMDIzLTAxLTAxVDAwOjAwOjAwLjE0OTc0NDIzMloiLCJsb2dnZWRfaW5fd2l0aF9zc28iOmZhbHNlLCJrZXkiOiIiLCJleHAiOjE2ODEyMTkyNzYsImlhdCI6MTY4MTIxNzQ3Nn0.K_85arIrigpkN1yHttCydpeT6oVg2c6PyQnuji907Og
curl --location "$BASEURL/api/rest/v1/tn/pledges/actions/approve" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "Authorization: Bearer $APIToken" \
--data '{
"ids": [
"24341e58-710a-43cc-9b11-35434bf5b49f"
],
"signature": "CunRoDLkcCLjSoraqYBryk8KmnstFBrvrMxX5qZQFiQOiNdt+f96BJ6ChVKN/6YmVCvfrcRPPXpY/y8J7NYuNA==",
"comment": "OK"
}
This piece of code sends a POST request to https://your-protect-instance.example.com/api/rest/v1/tn/pledges/actions/approve with the JSON string in the request body.
Call Result
A successful response for the POST call to create a pledge might look like this:
{"signatures":"1"}
In this example, a user has approved the pledge action.
Requirements for Future Use
For this particular endpoint, we do not have any storage requirements.
You can find the Swagger-generated page for this endpoint in the following link.
Updated 22 days ago