# Bitcoin PSBT Fordefi supports signing arbitrary Bitcoin transactions using the Partially Signed Bitcoin Transaction (PSBT) format. The following fields are required in the request body (within the `details` field). The `psbt_raw_data` field must contain the PSBT in its raw binary format. For general information on PSBTs, see the [BIP-174 specification](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki), which documents the PSBT format. In practice, you will probably use a library like [bitcoin-js](https://github.com/bitcoinjs/bitcoinjs-lib) to generate the PSBTs. The `sender` field must specify the vault address that will be used to sign the PSBT. Currently, Fordefi supports signing PSBTs only with Schnorr signatures using any of the vault's Taproot addresses. If you need to sign a PSBT with a Legacy or Segwit address, please contact Fordefi support. The `auto_finalize` field in the request body controls whether Fordefi will automatically finalize the PSBT after signing it. If your PSBT requires adding more signatures after signing it with your Fordefi vault, you should set `auto_finalize` to `false`. Similarly, the `push_mode` field controls whether Fordefi will push the signed transaction to the network. If your PSBT requires adding more signatures after signing it with your Fordefi vault, you should set `push_mode` to `manual`. The following is an example of the body of a [Create Transaction](/api/openapi/transactions/create_transaction_api_v1_transactions_post) request for a Bitcoin PSBT. The request should be signed, as demonstrated [here](/developers/authentication#request-signing). ```json { "vault_id": "3fd3ed32-64e5-47ef-b822-65493d30bf3f", "signer_type": "api_signer", "type": "utxo_transaction", "details": { "type": "utxo_partially_signed_bitcoin_transaction", "psbt_raw_data": "0x70736274ff01005e0200000001c23e3e8573df5c6746f7f060e6afe2421b9e5757318aa989d3119503454bfb4a0000000000fdffffff0140420f00000000002251200e8fe1beb4ccbc845a4a37cbd7a15ce0ac41ae2743f34c0a9dc388d5899b38ec000000000001012b60e316000000000022512068c00571d283f000be7962b97d839d93062050a2b6780cc9cca2691a37d28be02215c1b3034b6e8655ae58a818c3c587b434d625368795d1b13fcd0fb81b40941e0e9923206b085b16099839a79700f329aeb165ed7ae05a4dce8bcbcddbf400b0d800a040acc021166b085b16099839a79700f329aeb165ed7ae05a4dce8bcbcddbf400b0d800a04025011634253c4fe7f3cc69eb70b3d7d1fa4e1512d73f390d008a47eab9f0aed5fcd96870ab482116b3034b6e8655ae58a818c3c587b434d625368795d1b13fcd0fb81b40941e0e9905003eafb721011720b3034b6e8655ae58a818c3c587b434d625368795d1b13fcd0fb81b40941e0e990118201634253c4fe7f3cc69eb70b3d7d1fa4e1512d73f390d008a47eab9f0aed5fcd90000", "sender": { "address_type": "taproot", "chain": { "chain_type": "utxo", "unique_id": "bitcoin_testnet" }, "address": "tb1pdawc9gg3sqlqcx7wjrd6e972px0tgrvlr09tcmzxck5ernt4zxzsm3p4jy" }, "auto_finalize": "true", "push_mode": "auto" } } ``` ## Optional: Specify inputs to sign Fordefi automatically detects the inputs to sign from the way that the PSBT references the signing vault's public key, given in the `sender` field. Specifically: - **Key spending path**: When a PSBT input specifies the vault's public key as the input's internal key (given in the `PSBT_IN_TAP_INTERNAL_KEY = 0x17` PSBT field), Fordefi will sign that input with the vault's private key tweaked with the [default tweak](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#constructing-and-spending-taproot-outputs:~:text=If%20the%20spending%20conditions%20do%20not%20require%20a%20script%20path%2C%20the%20output%20key%20should%20commit%20to%20an%20unspendable%20script%20path%20instead%20of%20having%20no%20script%20path.%20This%20can%20be%20achieved%20by%20computing%20the%20output%20key%20point%20as%20Q%20%3D%20P%20%2B%20int(hashTapTweak(bytes(P)))G.). Support for signing PSBTs with the key path where the script path is non-empty is coming soon. - **Script spending path**: When a PSBT input contains a leaf script (given in the `PSBT_IN_TAP_LEAF_SCRIPT` PSBT field), and the leaf script contains the vault's public key, Fordefi will sign that input with the vault's private key, left untweaked. There is also an option to manually specify the inputs to sign, using the optional `inputs` field. However, in most cases, this field can be omitted, and the determination of which inputs to sign is left to Fordefi.