I know how to create and fund bitcoin transactions using createrawtransaction
and fundrawtransaction
methods. I tried to use the same methods in Elements to create a transaction on regtest and I'm a bit confused now.What I'm trying to do precisely is having a node who only have a watch-only wallet creates and funds transactions with the UTXOs it has on watch and sign later on another machine.
So I have this watch-only node, and it watches 2 outputs, one with L-BTC and the other with some asset, let's call it X.
I first create a transaction that have only one output of 0.5 asset X:e2-cli createrawtransaction "[]" "[{\"$ADDR\":0.5}]" 0 false "{\"$ADDR\":\"$ASSETX\"}"
Now I decode the transaction and I see this:
{"txid": "4d941354157530580ac49d97fad4690a5aab5b1a3bca4a38d7b26969455edec8","hash": "4d941354157530580ac49d97fad4690a5aab5b1a3bca4a38d7b26969455edec8","wtxid": "4d941354157530580ac49d97fad4690a5aab5b1a3bca4a38d7b26969455edec8","withash": "d0d3b17552f63780c06e5558483412d8384702cd777404f52a8a9680304fe582","version": 2,"size": 110,"vsize": 110,"weight": 440,"locktime": 0,"vin": [ ],"vout": [ {"value": 0.50000000,"asset": "ceefd76de1b71c2bed3de04481826287a80babb6e1f6c9feca14e57597742d74","commitmentnonce": "036c0c488e3bfb29090d0bda8be116088c61dcd3252a949f801972e8dc3f223c70","commitmentnonce_fully_valid": true,"n": 0,"scriptPubKey": {"asm": "OP_HASH160 eee6174735a3d1bca9532e663ec266acd59a6a1c OP_EQUAL","hex": "a914eee6174735a3d1bca9532e663ec266acd59a6a1c87","reqSigs": 1,"type": "scripthash","addresses": ["XZ8RJoGpd5GDRBGYuLrRq24bQBNtqCxgXG" ] } } ]}
Then I try to fund the transaction (I want to subtract fee from the change output for some reasons):e2-cli fundrawtransaction $RTX "{\"changeAddress\":\"$CHANGE\",\"changePosition\":0,\"subtractFeeFromOutputs\":[0],\"includeWatching\":true}"
And I have this error:
Wallet does not support more than one type of fee at a time, therefore can not subtract fee from address amount, which is of a different asset id. fee asset: b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23 recipient asset: ceefd76de1b71c2bed3de04481826287a80babb6e1f6c9feca14e57597742d74
And indeed if I convert it to psbt I see this:
{"inputs": [ ],"next": "extractor","estimated_vsize": 78,"estimated_feerate": 0.00000000,"fee": {"bitcoin": 0.00000000,"ceefd76de1b71c2bed3de04481826287a80babb6e1f6c9feca14e57597742d74": -0.50000000 }}
What am I missing here? I didn't put the "fee" key when I did createrawtransaction
, as far as I can tell, so why did my asset X output became a fee output?