Bitcoin Forum
June 29, 2025, 03:22:19 PM *
News: Latest Bitcoin Core release: 29.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to add a custom struct to PSBT and handle transaction fees using BIP-174  (Read 238 times)
nerses (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 4


View Profile
October 21, 2024, 09:28:25 AM
 #1

I am working on a Bitcoin transaction where two parties are involved. The goal is to lock funds and create a custom struct in the transaction output. Here's how I intend to set it up:

First party provides the funds and initiates a Partially Signed Bitcoin Transaction (PSBT) using BIP-174. Second party will add a custom struct (possibly metadata or a specific output detail) to the PSBT without providing any funds. I'm wondering if the following is possible:

Can the second party add a custom struct (output or metadata) to the PSBT, while the first party is the only one providing funds? Who will be responsible for paying the transaction fees? Will the first party bear all the fees since they are providing the input funds, or is there a way to distribute this between the parties? Are there any known constraints or best practices for achieving this within Bitcoin's protocol and the PSBT standard? I would appreciate any guidance on whether this setup is feasible and how to handle fees and struct addition in a PSBT.
nextidearly
Newbie
*
Offline Offline

Activity: 11
Merit: 0


View Profile
October 21, 2024, 04:37:27 PM
 #2

The second parity can be structured with a custom struct (output or metadata). As long as the first party is only the one providing funds, that will pay all the fees. Bitcoin blockchain don't support splitting fees. But splitting fees are the most important in your case, we can adjust it manually by controlling inputs and outputs of the transaction. I think you can practice with bitcoinjs-lib which is the library for Bitcoin PSBT, addresses, etc.
ABCbits
Legendary
*
Offline Offline

Activity: 3290
Merit: 8845



View Profile
October 22, 2024, 10:43:24 AM
Merited by Felicity_Tide (1)
 #3

I'm not expert on PSBT, but
1. BIP 370 (PSBT v2) improve BIP 174 (PSBT v0) which add more feature, mainly adding more input and output.
2. TX fee actually determined by subtract total coin on the input and total coin on the output. That means determining who's responsibility to pay TX fee entirely depends on all inputs and outputs.



Secondly  in the usual cases the party providing the fund usually bear the transaction fee but you can also distribute the fees between the two party by using
output tagging (BIP-68) or you can negotiate the fee distribution outside the protocol

BIP 68 isn't about output tagging. It's about timelock which determine when an UTXO can be spend, not about managing TX fee. Here's simple explanation about BIP 68 to other reader.

how bip68 works and how the relative lock-time using nsequence actually looks like can be seen very well in the 4 following slides




nerses (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 4


View Profile
October 24, 2024, 02:34:31 PM
 #4

I'm not expert on PSBT, but
1. BIP 370 (PSBT v2) improve BIP 174 (PSBT v0) which add more feature, mainly adding more input and output.
2. TX fee actually determined by subtract total coin on the input and total coin on the output. That means determining who's responsibility to pay TX fee entirely depends on all inputs and outputs.



Secondly  in the usual cases the party providing the fund usually bear the transaction fee but you can also distribute the fees between the two party by using
output tagging (BIP-68) or you can negotiate the fee distribution outside the protocol

BIP 68 isn't about output tagging. It's about timelock which determine when an UTXO can be spend, not about managing TX fee. Here's simple explanation about BIP 68 to other reader.


Thanks for explanation. By the way in what platform I can see your illustrations on Bitcoin topics ? I have found only X but it doesn't seems the best platform to investigate something
ABCbits
Legendary
*
Offline Offline

Activity: 3290
Merit: 8845



View Profile
October 25, 2024, 12:19:08 PM
 #5

--snip--
Thanks for explanation. By the way in what platform I can see your illustrations on Bitcoin topics ? I have found only X but it doesn't seems the best platform to investigate something

As i said previously, i never create any Bitcoin illustrations. But if you want to see more illustration created by @cygan, you can check https://twitter.com/BTCillustrated.

stanleyrivera219
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
April 08, 2025, 12:45:10 PM
 #6

Yes, the second party can add a custom struct (like metadata or specific output details) to the PSBT, even if they are not providing any funds. The first party, who is funding the transaction, will typically bear the transaction fees, as they control the input funds. However, there are ways to structure the transaction so that both parties share the fees. One approach is to allocate a portion of the funds for fees in the outputs or adjust the input amounts to account for the fees. The PSBT standard allows for flexibility in this regard, but it’s important to ensure that the transaction’s total size and inputs/outputs are correctly balanced. Best practices include clearly defining fee allocation in the agreement and verifying the final PSBT before signing.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!