Accept the counterparty's pending price
curl --request POST \
--url https://api.hashlock.markets/v1/threads/{id}/accept-proposal \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"quoteAmount": "<the pending price, base units — GET /v1/threads/{id}>",
"accept": true,
"hashlock": "<sha256(secret) hex — the initiator only>"
}
'import requests
url = "https://api.hashlock.markets/v1/threads/{id}/accept-proposal"
payload = {
"quoteAmount": "<the pending price, base units — GET /v1/threads/{id}>",
"accept": True,
"hashlock": "<sha256(secret) hex — the initiator only>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
quoteAmount: '<the pending price, base units — GET /v1/threads/{id}>',
accept: true,
hashlock: '<sha256(secret) hex — the initiator only>'
})
};
fetch('https://api.hashlock.markets/v1/threads/{id}/accept-proposal', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hashlock.markets/v1/threads/{id}/accept-proposal",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'quoteAmount' => '<the pending price, base units — GET /v1/threads/{id}>',
'accept' => true,
'hashlock' => '<sha256(secret) hex — the initiator only>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.hashlock.markets/v1/threads/{id}/accept-proposal"
payload := strings.NewReader("{\n \"quoteAmount\": \"<the pending price, base units — GET /v1/threads/{id}>\",\n \"accept\": true,\n \"hashlock\": \"<sha256(secret) hex — the initiator only>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.hashlock.markets/v1/threads/{id}/accept-proposal")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"quoteAmount\": \"<the pending price, base units — GET /v1/threads/{id}>\",\n \"accept\": true,\n \"hashlock\": \"<sha256(secret) hex — the initiator only>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hashlock.markets/v1/threads/{id}/accept-proposal")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"quoteAmount\": \"<the pending price, base units — GET /v1/threads/{id}>\",\n \"accept\": true,\n \"hashlock\": \"<sha256(secret) hex — the initiator only>\"\n}"
response = http.request(request)
puts response.read_body{
"thread": {
"id": "<string>",
"rfqId": "<string>",
"takerId": "<string>",
"makerId": "<string>",
"status": "open",
"takerAccepted": true,
"makerAccepted": true,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"currentQuoteAmount": "<string>",
"pendingAmount": "<string>",
"pendingBy": "<string>",
"hashlock": "<string>",
"counterpartyName": "<string>",
"counterpartyPicture": {},
"counterpartyStats": {
"swaps": 123,
"deals": 123,
"walkedAway": 123,
"fundSeconds": 123,
"revealSeconds": 123,
"fundSamples": 123,
"revealSamples": 123,
"since": "2023-11-07T05:31:56Z"
}
},
"swap": {
"id": "<string>",
"threadId": "<string>",
"status": "<string>",
"makerId": "<string>",
"takerId": "<string>",
"initiatorUserId": "<string>",
"hashlock": "<string>",
"aAssetId": "<string>",
"aChain": "<string>",
"aAmount": "<string>",
"aTimelock": "2023-11-07T05:31:56Z",
"bAssetId": "<string>",
"bChain": "<string>",
"bAmount": "<string>",
"bTimelock": "2023-11-07T05:31:56Z",
"rfqId": "<string>",
"secretCiphertext": "<string>",
"meta": {},
"feeBps": 123,
"feeAmount": "<string>",
"feeAssetId": "<string>",
"aPayoutAddress": "<string>",
"aClaimTo": "<string>",
"aRefundAddress": "<string>",
"aHtlcAddress": "<string>",
"aFundTx": "<string>",
"aFundOutpoints": [
{
"txid": "<string>",
"vout": 123,
"value": 123
}
],
"aClaimTx": "<string>",
"aRefundTx": "<string>",
"bPayoutAddress": "<string>",
"bClaimTo": "<string>",
"bRefundAddress": "<string>",
"bHtlcAddress": "<string>",
"bFundTx": "<string>",
"bFundOutpoints": [
{
"txid": "<string>",
"vout": 123,
"value": 123
}
],
"bClaimTx": "<string>",
"bRefundTx": "<string>",
"timeline": {
"fundA": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"fundB": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"reveal": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"payoutA": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"payoutB": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
}
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}Negotiation
Accept the counterparty's pending price
Name the price you are accepting: it is refused if a newer counter has replaced it since you read the thread. With accept: true it also accepts the deal at that price in the same transaction — COMMITS, like POST /v1/threads//accept — and, since proposing a price is agreeing to it, that agrees the deal (unless the proposer is the initiator and proposed without its hashlock — then its accept is left); the initiator taking a counter passes its hashlock here (a hashlock without accept: true is refused). Without accept, the taker’s accept is left afterwards (and the proposer’s too, when it is the initiator and proposed without its hashlock).
POST
/
v1
/
threads
/
{id}
/
accept-proposal
Accept the counterparty's pending price
curl --request POST \
--url https://api.hashlock.markets/v1/threads/{id}/accept-proposal \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"quoteAmount": "<the pending price, base units — GET /v1/threads/{id}>",
"accept": true,
"hashlock": "<sha256(secret) hex — the initiator only>"
}
'import requests
url = "https://api.hashlock.markets/v1/threads/{id}/accept-proposal"
payload = {
"quoteAmount": "<the pending price, base units — GET /v1/threads/{id}>",
"accept": True,
"hashlock": "<sha256(secret) hex — the initiator only>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
quoteAmount: '<the pending price, base units — GET /v1/threads/{id}>',
accept: true,
hashlock: '<sha256(secret) hex — the initiator only>'
})
};
fetch('https://api.hashlock.markets/v1/threads/{id}/accept-proposal', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hashlock.markets/v1/threads/{id}/accept-proposal",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'quoteAmount' => '<the pending price, base units — GET /v1/threads/{id}>',
'accept' => true,
'hashlock' => '<sha256(secret) hex — the initiator only>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.hashlock.markets/v1/threads/{id}/accept-proposal"
payload := strings.NewReader("{\n \"quoteAmount\": \"<the pending price, base units — GET /v1/threads/{id}>\",\n \"accept\": true,\n \"hashlock\": \"<sha256(secret) hex — the initiator only>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.hashlock.markets/v1/threads/{id}/accept-proposal")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"quoteAmount\": \"<the pending price, base units — GET /v1/threads/{id}>\",\n \"accept\": true,\n \"hashlock\": \"<sha256(secret) hex — the initiator only>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hashlock.markets/v1/threads/{id}/accept-proposal")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"quoteAmount\": \"<the pending price, base units — GET /v1/threads/{id}>\",\n \"accept\": true,\n \"hashlock\": \"<sha256(secret) hex — the initiator only>\"\n}"
response = http.request(request)
puts response.read_body{
"thread": {
"id": "<string>",
"rfqId": "<string>",
"takerId": "<string>",
"makerId": "<string>",
"status": "open",
"takerAccepted": true,
"makerAccepted": true,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"currentQuoteAmount": "<string>",
"pendingAmount": "<string>",
"pendingBy": "<string>",
"hashlock": "<string>",
"counterpartyName": "<string>",
"counterpartyPicture": {},
"counterpartyStats": {
"swaps": 123,
"deals": 123,
"walkedAway": 123,
"fundSeconds": 123,
"revealSeconds": 123,
"fundSamples": 123,
"revealSamples": 123,
"since": "2023-11-07T05:31:56Z"
}
},
"swap": {
"id": "<string>",
"threadId": "<string>",
"status": "<string>",
"makerId": "<string>",
"takerId": "<string>",
"initiatorUserId": "<string>",
"hashlock": "<string>",
"aAssetId": "<string>",
"aChain": "<string>",
"aAmount": "<string>",
"aTimelock": "2023-11-07T05:31:56Z",
"bAssetId": "<string>",
"bChain": "<string>",
"bAmount": "<string>",
"bTimelock": "2023-11-07T05:31:56Z",
"rfqId": "<string>",
"secretCiphertext": "<string>",
"meta": {},
"feeBps": 123,
"feeAmount": "<string>",
"feeAssetId": "<string>",
"aPayoutAddress": "<string>",
"aClaimTo": "<string>",
"aRefundAddress": "<string>",
"aHtlcAddress": "<string>",
"aFundTx": "<string>",
"aFundOutpoints": [
{
"txid": "<string>",
"vout": 123,
"value": 123
}
],
"aClaimTx": "<string>",
"aRefundTx": "<string>",
"bPayoutAddress": "<string>",
"bClaimTo": "<string>",
"bRefundAddress": "<string>",
"bHtlcAddress": "<string>",
"bFundTx": "<string>",
"bFundOutpoints": [
{
"txid": "<string>",
"vout": 123,
"value": 123
}
],
"bClaimTx": "<string>",
"bRefundTx": "<string>",
"timeline": {
"fundA": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"fundB": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"reveal": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"payoutA": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
},
"payoutB": {
"openedAt": "2023-11-07T05:31:56Z",
"deadline": "2023-11-07T05:31:56Z",
"doneAt": "2023-11-07T05:31:56Z",
"sentAt": "2023-11-07T05:31:56Z",
"heldAt": "2023-11-07T05:31:56Z",
"shortAt": "2023-11-07T05:31:56Z",
"unverifiedAt": "2023-11-07T05:31:56Z"
}
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}Authorizations
Body
application/json