获取兑换待签名 PSBT
获取兑换待签名 PSBT
预兑换请求成功,获取待签名 PSBT。其中,部分请求参数为预兑换返回结果。
export interface SwapPsbtBody {
send_coin_type: string;
send_tick: string;
send_amount: string;
receive_coin_type: string;
receive_tick: string;
receive_amount: string;
address: string;
btc_address: string;
slipper: string;
fee_rate: number;
ins: string[];
user_public_key: string;
tx_size: number;
checksum: number; // 预请求接口返回,这个字段注意,get_swap_psbt_txsize拿到的是check_sum,这边需要使用checksum
vins: string[]; // 预请求接口返回
usr_cnt: number;
}
{
"receive_amount": "864",
"receive_coin_type": "btc",
"receive_tick": "BTC",
"send_amount": "100",
"send_coin_type": "brc20",
"send_tick": "bqbq",
"slipper": 9,
"fee_rate": 11,
"ins": [
"22d16b84841c73a8e44db501b3e397aa6031e8a6e7092e2165e588c389ff9e8ci0"
],
"user_public_key": "02d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee81",
"address": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e",
"btc_address": "tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e",
"tx_size": 353,
"usr_cnt": 1,
"vins": [
"08df53b3c53cdf63e25024660f51c4f399b1de0539cfb29a6107202d387bf3ca:2",
"8c7109a72c63d6b8aefae3e1a9e4418a68610ec65b3f48b1cf035017299ec18a:1"
],
"checksum": "04ED4405DE7B5362B069759FCEA672B0"
}
curl 'https://test-api-proxy.ddpurse.com/brc20swap/get_swap_psbt' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Accept-Language: en' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: http://localhost:56651' \
-H 'Pragma: no-cache' \
-H 'Referer: http://localhost:56651/' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: cross-site' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw '{"receive_amount":"864","receive_coin_type":"btc","receive_tick":"BTC","send_amount":"100","send_coin_type":"brc20","send_tick":"bqbq","slipper":9,"fee_rate":11,"ins":["22d16b84841c73a8e44db501b3e397aa6031e8a6e7092e2165e588c389ff9e8ci0"],"user_public_key":"02d3ac7452920b1cc4653516dd4f4381a2df0a8c0aac6e3446e633a73ea63eee81","address":"tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e","btc_address":"tb1qge80xavle7c7k0tk7vceaavwcgpsr3jchl0w3e","tx_size":353,"usr_cnt":1,"vins":["08df53b3c53cdf63e25024660f51c4f399b1de0539cfb29a6107202d387bf3ca:2","8c7109a72c63d6b8aefae3e1a9e4418a68610ec65b3f48b1cf035017299ec18a:1"],"checksum":"04ED4405DE7B5362B069759FCEA672B0"}' \
--compressed
1、获取到待签名 PSBT 之后,用户必须在 30 秒内签名
2、注意 checksum
字段,值是从上个接口获取,但是字段名称有差异
1、获取到待签名 PSBT 之后,用户必须在 30 秒内签名
2、btc_address
和 address
传同一个地址即可
3、user_public_key
传参方法为只有一个地址的钱包 public_key
:public_key
,有两个地址的钱包 btc_public_key
:ordi_public_key
Last updated