Language

Choose a language

/build/rpc / contracts / repo

repo.propose

  • workflowrepo-lifecycle·step 1 of 10Workflow: repo-lifecycle · step 1 of 10

repo.propose {"principal_asset_id":"hex","principal_is_native":bool,"principal_units":n,"interest_units":n,"repay_units":n,"collateral_sats":n,"collateral_btc":n,"maturity_height":n,"safety_k":n,"reorg_conf":n,"borrower_address":"str","lender_address":"str","fee_policy":"str"} Create a repo financing offer skeleton and store it in the wallet registry. Arguments: 1. terms (json object, required) Repo contract terms { "principal_asset_id": "hex", (string, optional) 32-byte asset identifier for principal leg (omit when native) "principal_is_native": bool, (boolean, optional) Set true when borrowing BTC "principal_units": n, (numeric, required) Asset units lent at open "interest_units": n, (numeric, required) Asset units owed as interest "repay_units": n, (numeric, optional) Total units owed (defaults to principal + interest) "collateral_sats": n, (numeric, optional) Collateral in satoshis "collateral_btc": n, (numeric, optional) Collateral in BTC "maturity_height": n, (numeric, required) Block height when default path activates "safety_k": n, (numeric, optional) Safety window before maturity (default 6) "reorg_conf": n, (numeric, optional) Reorg confirmations buffer (default 2) "borrower_address": "str", (string, required) Borrower covenant address (bech32m) "lender_address": "str", (string, required) Lender repayment address (bech32m) "fee_policy": "str", (string, optional) Fee policy strategy: 'low' (~2 sat/vB), 'medium' (~10 sat/vB), or 'high' (~50 sat/vB). Default: 'medium' } Result: { (json object) "offer_id" : "hex", (string) Unique offer identifier "offer" : { (json object) Offer payload to share with counterparty "version" : n, (numeric) Offer payload version "contract_type" : "str", (string) Contract type (repo) "id" : "hex", (string) Offer identifier "terms" : { (json object) Canonicalised repo terms "principal_leg" : { (json object) Principal asset leg "is_native" : true|false, (boolean) True when the leg is denominated in BTC "asset_id" : "hex", (string, optional) 32-byte asset identifier when non-native "units" : n (numeric) Exact units (sats or asset units) delivered }, "interest_leg" : { (json object) Interest asset leg "is_native" : true|false, (boolean) True when the leg is denominated in BTC "asset_id" : "hex", (string, optional) 32-byte asset identifier when non-native "units" : n (numeric) Exact units (sats or asset units) delivered }, "collateral_leg" : { (json object) Collateral asset leg "is_native" : true|false, (boolean) True when the leg is denominated in BTC "asset_id" : "hex", (string, optional) 32-byte asset identifier when non-native "units" : n (numeric) Exact units (sats or asset units) delivered }, "principal_is_native" : true|false, (boolean) True when the principal leg is denominated in BTC "principal_asset_id" : "hex", (string, optional) 32-byte asset identifier for non-native principal legs "asset_id" : "hex", (string, optional) Compatibility alias for principal asset id (null when native) "principal_units" : n, (numeric) Principal units (or sats when native) delivered at open "interest_units" : n, (numeric) Fixed interest units owed by the borrower "repay_units" : n, (numeric) Total units owed at repayment "collateral_sats" : n, (numeric, optional) BTC collateral amount (only when collateral is native) "collateral_sats_raw" : n, (numeric, optional) Collateral in satoshis (only when collateral is native) "maturity_height" : n, (numeric) Block height activating the default branch "safety_k" : n, (numeric) Pre-maturity safety window used for UX warnings "reorg_conf" : n (numeric) Confirmations required past maturity before default sweep }, "sinks" : { (json object) Canonical sink set "collateral_spk" : "hex", (string) Hex-encoded Taproot script for the collateral vault "repay_spk" : "hex" (string) Hex-encoded Taproot script for the repayment sink }, "fs_policy" : { (json object) Fair-Sign policy "require_adaptor" : true|false, (boolean) Require adaptor signatures (Fair-Sign) "reveal_lockstep" : true|false (boolean) Enforce lock-step final signature reveal }, "fs_tx_adaptor_point" : "hex", (string) Global adaptor point (x-only, hex) "salt" : "hex", (string) Salt used when computing the commitment "commitment" : "hex", (string) Commitment hash "created_height" : n, (numeric) Wallet chain height when the offer was recorded "created_time" : xxx, (numeric) Wall-clock creation timestamp "borrower_address" : "str", (string) Borrower covenant address (bech32m) "lender_address" : "str", (string) Initial repayment address (bech32m) "lender_internal_key" : "hex", (string, optional) Untweaked lender key used in default covenant leaf (x-only, hex) "borrower_internal_key" : "hex", (string, optional) Untweaked borrower key (x-only, hex) "maker_role" : "str", (string, optional) Which side created the offer (borrower or lender) "fee_policy_strategy" : "str", (string, optional) Fee policy strategy used for the contract "repay_address_override" : "str", (string, optional) Current repayment override "vault" : { (json object, optional) Tracked collateral vault outpoint once known "txid" : "hex", (string) Vault funding transaction id "vout" : n, (numeric) Vault output index "amount" : n (numeric) Vault amount in BTC }, "acceptance" : { (json object, optional) Counterparty acceptance payload "version" : n, (numeric) Acceptance payload version "contract_type" : "str", (string) Contract type (repo) "offer_id" : "hex", (string) Offer identifier "id" : "hex", (string) Acceptance identifier "sinks_ack" : { (json object) Acknowledged sink set "repay_spk" : "hex" (string) Hex-encoded Taproot repayment script acknowledged by the counterparty }, "fs_policy_ack" : { (json object) Acknowledged Fair-Sign policy "require_adaptor" : true|false, (boolean) Require adaptor signatures (Fair-Sign) "reveal_lockstep" : true|false (boolean) Enforce lock-step final signature reveal }, "fs_tx_adaptor_point" : "hex", (string) Counterparty adaptor point (x-only, hex) "salt" : "hex", (string) Acceptance salt "commitment" : "hex", (string) Acceptance commitment "borrower_internal_key" : "hex", (string, optional) Borrower's internal key for vault construction (x-only, hex) "lender_internal_key" : "hex", (string, optional) Untweaked lender key (x-only, hex) "repay_templates" : [ (json array, optional) Pre-built repayment delivery templates { (json object) "purpose" : "str", (string) Template purpose (repay_principal, repay_interest, or repay_merged) "is_native" : true|false, (boolean) Whether repayment is native BTC "units" : n, (numeric) Raw units represented by the template "script_pubkey" : "hex", (string) Destination scriptPubKey "commitment" : "hex", (string) Commitment hash over script and TLV metadata "asset_id" : "hex", (string, optional) Asset identifier when non-native "vext" : "hex" (string, optional) Asset TLV bytes when non-native }, ... ], "default_collateral_template" : { (json object, optional) Pre-built collateral sweep template "purpose" : "str", (string) Template purpose (default_collateral) "is_native" : true|false, (boolean) Whether sweep is native BTC "units" : n, (numeric) Raw units represented by the template "script_pubkey" : "hex", (string) Destination scriptPubKey "commitment" : "hex", (string) Commitment hash over script and TLV metadata "asset_id" : "hex", (string, optional) Asset identifier when non-native "vext" : "hex" (string, optional) Asset TLV bytes when non-native } }, "repay_tx" : { (json object, optional) Repayment transaction details once detected "txid" : "hex", (string) Repayment transaction id "height" : n, (numeric, optional) Block height when repayment was confirmed "time" : xxx (numeric, optional) Timestamp when repayment was confirmed }, "default_tx" : { (json object, optional) Default/liquidation transaction details once detected "txid" : "hex", (string) Default transaction id "height" : n, (numeric, optional) Block height when default was confirmed "time" : xxx (numeric, optional) Timestamp when default was confirmed } } } Examples: > bitcoin-cli repo.propose "{\"principal_asset_id\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"principal_units\":1000000,\"interest_units\":50000,\"collateral_btc\":2,\"maturity_height\":850000,\"borrower_address\":\"bcrt1...\",\"lender_address\":\"bcrt1...\"}"

Signature

repo.propose(terms: object) → any

Code samples

curl --user "$RPC_USER:$RPC_PASS" \
  --data-binary '{"jsonrpc":"1.0","id":"docs","method":"repo.propose","params":[{}]}' \
  -H 'content-type: text/plain;' \
  http://127.0.0.1:8332/

Parameters

NameTypeReq.Description
termsobjectyesRepo contract terms { "principal_asset_id": "hex", (string, optional) 32-byte asset identifier for principal leg (omit when native) "principal_is_native": bool, (boolean, optional) Set true when borrowing BTC "principal_units": n, (numeric, required) Asset units lent at open "interest_units": n, (numeric, required) Asset units owed as interest "repay_units": n, (numeric, optional) Total units owed (defaults to principal + interest) "collateral_sats": n, (numeric, optional) Collateral in satoshis "collateral_btc": n, (numeric, optional) Collateral in BTC "maturity_height": n, (numeric, required) Block height when default path activates "safety_k": n, (numeric, optional) Safety window before maturity (default 6) "reorg_conf": n, (numeric, optional) Reorg confirmations buffer (default 2) "borrower_address": "str", (string, required) Borrower covenant address (bech32m) "lender_address": "str", (string, required) Lender repayment address (bech32m) "fee_policy": "str", (string, optional) Fee policy strategy: 'low' (~2 sat/vB), 'medium' (~10 sat/vB), or 'high' (~50 sat/vB). Default: 'medium' }

Result

Type:  any

{ (json object) "offer_id" : "hex", (string) Unique offer identifier "offer" : { (json object) Offer payload to share with counterparty "version" : n, (numeric) Offer payload version "contract_type" : "str", (string) Contract type (repo) "id" : "hex", (string) Offer identifier "terms" : { (json object) Canonicalised repo terms "principal_leg" : { (json object) Principal asset leg "is_native" : true|false, (boolean) True when the leg is denominated in BTC "asset_id" : "hex", (string, optional) 32-byte asset identifier when non-native "units" : n (numeric) Exact units (sats or asset units) delivered }, "interest_leg" : { (json object) Interest asset leg "is_native" : true|false, (boolean) True when the leg is denominated in BTC "asset_id" : "hex", (string, optional) 32-byte asset identifier when non-native "units" : n (numeric) Exact units (sats or asset units) delivered }, "collateral_leg" : { (json object) Collateral asset leg "is_native" : true|false, (boolean) True when the leg is denominated in BTC "asset_id" : "hex", (string, optional) 32-byte asset identifier when non-native "units" : n (numeric) Exact units (sats or asset units) delivered }, "principal_is_native" : true|false, (boolean) True when the principal leg is denominated in BTC "principal_asset_id" : "hex", (string, optional) 32-byte asset identifier for non-native principal legs "asset_id" : "hex", (string, optional) Compatibility alias for principal asset id (null when native) "principal_units" : n, (numeric) Principal units (or sats when native) delivered at open "interest_units" : n, (numeric) Fixed interest units owed by the borrower "repay_units" : n, (numeric) Total units owed at repayment "collateral_sats" : n, (numeric, optional) BTC collateral amount (only when collateral is native) "collateral_sats_raw" : n, (numeric, optional) Collateral in satoshis (only when collateral is native) "maturity_height" : n, (numeric) Block height activating the default branch "safety_k" : n, (numeric) Pre-maturity safety window used for UX warnings "reorg_conf" : n (numeric) Confirmations required past maturity before default sweep }, "sinks" : { (json object) Canonical sink set "collateral_spk" : "hex", (string) Hex-encoded Taproot script for the collateral vault "repay_spk" : "hex" (string) Hex-encoded Taproot script for the repayment sink }, "fs_policy" : { (json object) Fair-Sign policy "require_adaptor" : true|false, (boolean) Require adaptor signatures (Fair-Sign) "reveal_lockstep" : true|false (boolean) Enforce lock-step final signature reveal }, "fs_tx_adaptor_point" : "hex", (string) Global adaptor point (x-only, hex) "salt" : "hex", (string) Salt used when computing the commitment "commitment" : "hex", (string) Commitment hash "created_height" : n, (numeric) Wallet chain height when the offer was recorded "created_time" : xxx, (numeric) Wall-clock creation timestamp "borrower_address" : "str", (string) Borrower covenant address (bech32m) "lender_address" : "str", (string) Initial repayment address (bech32m) "lender_internal_key" : "hex", (string, optional) Untweaked lender key used in default covenant leaf (x-only, hex) "borrower_internal_key" : "hex", (string, optional) Untweaked borrower key (x-only, hex) "maker_role" : "str", (string, optional) Which side created the offer (borrower or lender) "fee_policy_strategy" : "str", (string, optional) Fee policy strategy used for the contract "repay_address_override" : "str", (string, optional) Current repayment override "vault" : { (json object, optional) Tracked collateral vault outpoint once known "txid" : "hex", (string) Vault funding transaction id "vout" : n, (numeric) Vault output index "amount" : n (numeric) Vault amount in BTC }, "acceptance" : { (json object, optional) Counterparty acceptance payload "version" : n, (numeric) Acceptance payload version "contract_type" : "str", (string) Contract type (repo) "offer_id" : "hex", (string) Offer identifier "id" : "hex", (string) Acceptance identifier "sinks_ack" : { (json object) Acknowledged sink set "repay_spk" : "hex" (string) Hex-encoded Taproot repayment script acknowledged by the counterparty }, "fs_policy_ack" : { (json object) Acknowledged Fair-Sign policy "require_adaptor" : true|false, (boolean) Require adaptor signatures (Fair-Sign) "reveal_lockstep" : true|false (boolean) Enforce lock-step final signature reveal }, "fs_tx_adaptor_point" : "hex", (string) Counterparty adaptor point (x-only, hex) "salt" : "hex", (string) Acceptance salt "commitment" : "hex", (string) Acceptance commitment "borrower_internal_key" : "hex", (string, optional) Borrower's internal key for vault construction (x-only, hex) "lender_internal_key" : "hex", (string, optional) Untweaked lender key (x-only, hex) "repay_templates" : [ (json array, optional) Pre-built repayment delivery templates { (json object) "purpose" : "str", (string) Template purpose (repay_principal, repay_interest, or repay_merged) "is_native" : true|false, (boolean) Whether repayment is native BTC "units" : n, (numeric) Raw units represented by the template "script_pubkey" : "hex", (string) Destination scriptPubKey "commitment" : "hex", (string) Commitment hash over script and TLV metadata "asset_id" : "hex", (string, optional) Asset identifier when non-native "vext" : "hex" (string, optional) Asset TLV bytes when non-native }, ... ], "default_collateral_template" : { (json object, optional) Pre-built collateral sweep template "purpose" : "str", (string) Template purpose (default_collateral) "is_native" : true|false, (boolean) Whether sweep is native BTC "units" : n, (numeric) Raw units represented by the template "script_pubkey" : "hex", (string) Destination scriptPubKey "commitment" : "hex", (string) Commitment hash over script and TLV metadata "asset_id" : "hex", (string, optional) Asset identifier when non-native "vext" : "hex" (string, optional) Asset TLV bytes when non-native } }, "repay_tx" : { (json object, optional) Repayment transaction details once detected "txid" : "hex", (string) Repayment transaction id "height" : n, (numeric, optional) Block height when repayment was confirmed "time" : xxx (numeric, optional) Timestamp when repayment was confirmed }, "default_tx" : { (json object, optional) Default/liquidation transaction details once detected "txid" : "hex", (string) Default transaction id "height" : n, (numeric, optional) Block height when default was confirmed "time" : xxx (numeric, optional) Timestamp when default was confirmed } } }

Source: services/core-node/bcore/src/wallet/rpc/contracts.cpp:2604

C++ symbol: repo_propose