There are presently three alternative ways to do that: uncooked transactions, PSBT in 0.17, and PSBT in 0.18. I like to recommend that you simply use PSBT in 0.18 as it’s the least problem, however I’ll describe all three right here for you.
Historically, you’ll do that with createrawtransaction
, fundrawtransaction
, and signrawtransactionwithkey
/signrawtransactionwithwallet
. One particular person must know all the inputs that had been getting used within the transaction or have all of these saved of their pockets (i.e. they’ve imported everybody else’s public keys and/or redeemScripts into their pockets) after which they’ll use createrawtransaction
or fundrawtransaction
to create the uncooked transaction.
createrawtransaction
simply takes inputs and outputs which might be specified by the person and provides the ensuing transaction as is (so you have to watch out about charges and alter). fundrawtransaction
can select the inputs to make use of for you utilizing your pockets and it’ll deal with charges and alter outputs itself. Nonetheless fundrawtransaction
must know all the data essential to assemble the ultimate transaction (apart from the personal key, it might simply use a dummy signature) to be able to accurately estimate the transaction charges, which is why you have to import the general public keys and scripts into your pockets.
After getting the uncooked transaction, you then ship it to every of the opposite folks concerned within the transaction. They then signal it utilizing signrawtransactionwithwallet
(if the keys and scripts are of their pockets) or signrawtransactionwithkey
(if their keys and scripts aren’t of their pockets). Most individuals will use signrawtransactionwithwallet
. They then ship the end result again to you the place you need to mix all the signed transactions into the ultimate transaction utilizing combinerawtransaction
. Then you possibly can broadcast it with sendrawtransaction
.
As an alternative of sending the transactions out to everybody to signal on the similar time, you possibly can ship to at least one one that indicators, who then sends to the following particular person and so forth. This is able to not require combinerawtransaction
. The final particular person would signal after which use sendrawtransaction
to broadcast.
This course of is sort of cumbersome and requires that one particular person is aware of some (or all) of the data for the inputs getting used (apart from the personal keys).
Since Bitcoin Core 0.17, you should use the varied *psbt
RPCs to attain the identical factor. With 0.17, the move is pretty much like the the uncooked transaction move described earlier. You would need to have all the data for creating the ultimate transaction in your pockets (besides for personal keys) in order that price estimation will be correctly carried out for coin choice, or you have to know which inputs to make use of. Both manner, you employ walletcreatefundedpsbt
and specify the inputs you need and the outputs you need. Bitcoin Core will then robotically select further inputs if there’s not sufficient to cowl the output quantity and create a change output for you. As a result of it must additionally conver transaction charges, it must have the identical data that you simply want for fundrawtransaction
to have the ability to estimate charges for the inputs it chooses.
You then would ship the transaction to everybody else who would add their signatures (and different metadata) utilizing walletprocesspsbt
. You may as well do walletprocesspsbt
first earlier than sending the transaction to everybody in order that varied metadata wanted for signing (just like the UTXO that’s being spent for every enter) is added beforehand. As soon as signed, everybody would ship the transaction again to you and also you mix them collectively utilizing combinepsbts
You then create the ultimate transaction for broadcast utilizing finalizepsbt
and ship the end result utilizing sendrawtransaction.
In fact utilizing PSBTs you are able to do the identical factor described above the place every particular person sends the transaction to the following particular person to be signed as an alternative of sending again to you to be mixed.
Once more, this course of is sort of cumbersome and requires that one particular person is aware of some (or all) of data for the inputs getting used (apart from the personal keys). However it’s barely much less prone to lead to an error than the uncooked transaction technique. PSBTs additionally lets you use different non-Bitcoin Core wallets that help PSBT, and you should use this technique with wallets which aren’t linked to the web or in any other case should not have the blockchain or the UTXOs which might be being spent within the transaction.
Nonetheless, Bitcoin Core 0.18 really makes this entire course of so much simpler. Bitcoin Core 0.18 introduces a few new *psbt
RPCs which make it in order that one particular person doesn’t must know all the inputs getting used and all the data for every enter. The one caveat is that this technique assumes that every particular person has their very own outputs that they wish to create as an alternative of a number of folks pooling collectively their Bitcoin to make one giant output.
With 0.18, everybody would create their very own PSBT utilizing walletcreatefundedpsbt
. They specify any of their very own inputs that they wish to use and all of their outputs. Any change outputs will likely be added, and extra inputs from the pockets will likely be added to cowl the output quantity and transaction price if not sufficient had been specified by the person. Since each person does this with their very own pockets, nobody particular person must know something about what the opposite customers have of their wallets.
Then every particular person would ship the PSBT to a delegated coordinator who makes use of joinpsbts
to hitch each PSBT into one giant PSBT. This PSBT could have all the inputs and outputs that every particular person needs to spend and create. So as an alternative of getting many particular person PSBTs with their very own inputs and outputs, there’s now one giant PSBT with everybody’s inputs and outputs.
This PSBT is then despatched again to every one that makes use of walletprocesspsbt
to replace the PSBT and add their enter data to the PSBT and indicators it. Even when a person has an airgapped setup the place their personal keys are someplace that doesn’t have entry to the blockchain, they’ll replace the PSBT from an internet watching solely pockets and ship the PSBT to the offline machine to be signed.
As soon as everybody has signed the PSBT, it’s despatched again to the coordinator who makes use of combinepsbt
to mix all the signatures and enter data into the identical PSBT, then creates the ultimate community transaction utilizing finalizepsbt
and broadcasts it utilizing sendrawtransaction
.
Once more, this may be carried out serially like the opposite strategies described earlier and thus omit the necessity for combinepsbt
.