/build/rpc / cosign / cross_chain
cosign.eth_lock_htlc
- workflowcross-chain-swap·step 4 of 7Workflow: cross-chain-swap · step 4 of 7
cosign.eth_lock_htlc "htlc_address" "swap_id" "recipient" "secret_hash" timelock "amount_wei" "signing_key" ( "token_address" gas_limit max_fee_gwei max_priority_fee_gwei ) Lock ETH or ERC-20 tokens into the HTLC contract. Arguments: 1. htlc_address (string, required) HTLC contract address 2. swap_id (string, required) 32-byte swap ID (hex) 3. recipient (string, required) Recipient address 4. secret_hash (string, required) sha256(secret) (hex) 5. timelock (numeric, required) Refund-eligible unix timestamp 6. amount_wei (string, required) Amount in wei (hex) 7. signing_key (string, required) 32-byte private key (hex) 8. token_address (string, optional) ERC-20 token address (null for native ETH) 9. gas_limit (numeric, optional) Gas limit (default 200000) 10. max_fee_gwei (numeric, optional) Max fee in gwei (default 50) 11. max_priority_fee_gwei (numeric, optional) Max priority fee in gwei (default 2) Result: { (json object) "success" : true|false, (boolean) Whether broadcast succeeded "tx_hash" : "str", (string) Transaction hash "from" : "str", (string) Sender address "nonce" : n (numeric) Transaction nonce } Examples: > bitcoin-cli cosign.eth_lock_htlc "0xHTLC" "0xSWAPID" "0xRECIPIENT" "0xSECRETHASH" 1234567890 "0xAMOUNT" "0xKEY"
Signature
cosign.eth_lock_htlc(htlc_address: string, swap_id: string, recipient: string, secret_hash: string, timelock: number, amount_wei: string, signing_key: string, token_address?: string, gas_limit?: number, max_fee_gwei?: number, max_priority_fee_gwei?: number) → any Code samples
curl --user "$RPC_USER:$RPC_PASS" \
--data-binary '{"jsonrpc":"1.0","id":"docs","method":"cosign.eth_lock_htlc","params":["\"<htlc_address>\"","\"<swap_id>\"","\"<recipient>\"","\"<secret_hash>\"",0,"\"<amount_wei>\"","\"<signing_key>\"","\"<token_address>\"",0,0,0]}' \
-H 'content-type: text/plain;' \
http://127.0.0.1:8332/ Parameters
| Name | Type | Req. | Description |
|---|---|---|---|
| htlc_address | string | yes | HTLC contract address |
| swap_id | string | yes | 32-byte swap ID (hex) |
| recipient | string | yes | Recipient address |
| secret_hash | string | yes | sha256(secret) (hex) |
| timelock | number | yes | Refund-eligible unix timestamp |
| amount_wei | string | yes | Amount in wei (hex) |
| signing_key | string | yes | 32-byte private key (hex) |
| token_address | string | — | ERC-20 token address (null for native ETH) |
| gas_limit | number | — | Gas limit (default 200000) |
| max_fee_gwei | number | — | Max fee in gwei (default 50) |
| max_priority_fee_gwei | number | — | Max priority fee in gwei (default 2) |
Result
Type: any
{ (json object) "success" : true|false, (boolean) Whether broadcast succeeded "tx_hash" : "str", (string) Transaction hash "from" : "str", (string) Sender address "nonce" : n (numeric) Transaction nonce }
Source: services/core-node/bcore/src/rpc/cosign.cpp:3375
C++ symbol: cosign_eth_lock_htlc