- Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Hi all. In our library, which is targeted towards offline signing, we currently only support legacy bitcoin addresses and are using bitgo-utxo-lib.
I now want to improve our library and add segwit support. This library here seems to be more up to date, so I'm planning on switching.
My goal is the following:
- Support for
bc1segwit address generation/sending/signing, with all address types as possible recipients - Signing with PSBT
- RBF support
Would this be considered the best practice for a bitcoin wallet at the moment?
While trying to implement this, I ran into a couple of issues:
How to deal with xPub, yPub and zPub
I usually use https://iancoleman.io/bip39/ as a reference. I noticed that when I select the "BIP44", "BIP49" and "BIP84" tabs, the the extended public keys have a different prefix (xPub, yPub, zPub for mainnet and tPub, uPub, vPub for testnet).
At first I ignored it, but when I sent the xPub to blockbook to get my UTXOs, I got an empty array back with my xPub, but it worked with the zPub key.
I read some discussions around this (#927, #1334, trezor/connect#98), but I'm not sure what the current state is. It was mentioned that it was not in the BIP49 standard, but now it seems to be there: https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki#extended-key-version
So what is the proper way to handle this?
PSBT signing support
We currently get the UTXOs from an API on an online device, select the inputs we want and then send this in a custom JSON structure to our signer. The signer takes the values and creates a transaction using the TransactionBuilder and signs them, completely offline.
It seems to me that the best way going forward would be to use the PSBT standard to do that. I read the BIP174, but it's not clear to me what different cases need to be handled by the signer.
In our online wallet, when preparing the transaction, we will only have segwit addresses as the origin. But our signer should be able to also handle PSBTs that come from Electrum/Coldcard/etc. So using the example here, would I be able to sign every possible valid transaction that can be given to the signer via PSBT? (Legacy addresses, segwit addresses, custom scripts, timelock, etc). Or is there some additional work required to handle all the different cases?
RBF (Replace by fee)
It seems that this was requested by a couple of people, but a long time ago the decision was made to not include it in this library #521.
Are there any plans to reconsider this? As far as I've seen, this seems like one of the features people see as a standard in bitcoin wallets.
If this is not planned, are there any other projects/examples that handle this and are compatible with this library?
Thanks a lot for taking the time to answer. I spent days reading about all of these issues, but it's hard to find concrete and up-to-date answers because the ecosystem is constantly evolving. I hope you can shed some light on this so I know what I should try to implement 😃.
BTW: The library and apps that will use this are completely open source, so once I have it working I would be willing to create some example scripts that can be added to this library so other people can learn from them as well.