Is it possible to make a "joint transaction"?

+1 vote

Hello,

Is it possible to make a "joint transaction"?

Consider this scenario:

  • on a blockchain there is an asset called asset1

  • there is a total of 1500 units of asset1

  • A owns 1000 units of asset1

  • B owns 500 units of asset1

  • both A and B say they want to send their part of asset1 to C

I desire a single transaction signed by both A and B. I tried createrawtransaction and appendrawtransaction, but I get ‘16: ConnectInputs failed’.
To get inputs I used gettxout <issue_txid_1> 0 and gettxout <issue_txid_2> 0 which show me the correct quantities of said asset.

The asset has just been issued in aforementioned quantities, to 2 different addresses (A and B).


 

Am I doing something wrong?

Thank you very much.

 

asked Nov 15, 2018 by multichain_user123

2 Answers

+2 votes
 
Best answer

Yes, you should use createrawtransaction and appendrawtransaction for this.

Both A and B should first use preparelockunspentfrom to prepare the appropriate quantity for spending in an unspent transaction output. The corresponding txid+vout combination should be used by each as their input for the transaction being built in the createrawtransaction and appendrawtransaction calls respectively. Then B has to sign the full transaction using signrawtransaction before passing it back to A to do the same, and finally broadcasting it.

If you want to get more clever, you can actually do this with less back-and-forth, since A can build the partial transaction and then sign it with signrawtransaction using a sighashtype of ALL|ANYONE_CAN_PAY before passing the result to B for adding the new input and final signing.

answered Nov 16, 2018 by MultiChain
selected Nov 16, 2018 by multichain_user123
Thank you very much.

I was missing ‘preparelockunspent’ to gather inputs and I was using issue_txid directly.

What happens if last user maliciously stalls (does not sign and of course does not broadcast)?
Nothing happens at all in terms of the blockchain until the transaction is fully balanced and broadcast. So the only issue will be that UTXOs can be "locked" and this is easily solved using the lockunspent API (which also unlocks).
Thank you very much.
+1 vote

You can use multisignature for this scenario. 

https://www.multichain.com/developers/multisignature-transactions/

If you decide to use multisignature please follow the below steps .

1) Create a multisignature address by keying in the pubkeys of both A and B.

2) Transfer assets of A and B to this newly created multisignature address.

3) Create raw transaction from either A or B  to C and sign the transaction. Upon signing a long hex output is displayed.

4) Copy the hex and sign it from the other node as well. Once signed the complete flag will be displayed as true which means it can be sent. 

answered Nov 15, 2018 by jeshocarmel
Hello and thanks for your answer.

I had considered multi-signature transactions. They would be perfect if A and B trusted each other, which is not always the case.
What happens if A says she will send asset1 to multisig-address1 (but she doesn’t) and B, who believes A, actually sends her part of asset1 to multisig-address1?
A gets to keep her part of the asset and B loses it, since both public key are now required to spend fund from multisig-address1, right? Is there a way to roll back for A?
There are other scenarios which are similar to this one.

My point is: what happens when owners of involved public keys no longer get along with each other? Is there a ‘roll back’ for users which sent assets to a multi-signature address?

Thanks again.
...