How does `createrawtransaction` and `fundrawtransaction` work with Elements? 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 &quot;[]&quot; &quot;[{\&quot;$ADDR\&quot;:0.5}]&quot; 0 false &quot;{\&quot;$ADDR\&quot;:\&quot;$ASSETX\&quot;}&quot;
Now I decode the transaction and I see this:
{
  &quot;txid&quot;: &quot;4d941354157530580ac49d97fad4690a5aab5b1a3bca4a38d7b26969455edec8&quot;,
  &quot;hash&quot;: &quot;4d941354157530580ac49d97fad4690a5aab5b1a3bca4a38d7b26969455edec8&quot;,
  &quot;wtxid&quot;: &quot;4d941354157530580ac49d97fad4690a5aab5b1a3bca4a38d7b26969455edec8&quot;,
  &quot;withash&quot;: &quot;d0d3b17552f63780c06e5558483412d8384702cd777404f52a8a9680304fe582&quot;,
  &quot;version&quot;: 2,
  &quot;size&quot;: 110,
  &quot;vsize&quot;: 110,
  &quot;weight&quot;: 440,
  &quot;locktime&quot;: 0,
  &quot;vin&quot;: [
  ],
  &quot;vout&quot;: [
    {
      &quot;value&quot;: 0.50000000,
      &quot;asset&quot;: &quot;ceefd76de1b71c2bed3de04481826287a80babb6e1f6c9feca14e57597742d74&quot;,
      &quot;commitmentnonce&quot;: &quot;036c0c488e3bfb29090d0bda8be116088c61dcd3252a949f801972e8dc3f223c70&quot;,
      &quot;commitmentnonce_fully_valid&quot;: true,
      &quot;n&quot;: 0,
      &quot;scriptPubKey&quot;: {
        &quot;asm&quot;: &quot;OP_HASH160 eee6174735a3d1bca9532e663ec266acd59a6a1c OP_EQUAL&quot;,
        &quot;hex&quot;: &quot;a914eee6174735a3d1bca9532e663ec266acd59a6a1c87&quot;,
        &quot;reqSigs&quot;: 1,
        &quot;type&quot;: &quot;scripthash&quot;,
        &quot;addresses&quot;: [
          &quot;XZ8RJoGpd5GDRBGYuLrRq24bQBNtqCxgXG&quot;
        ]
      }
    }
  ]
}

Then I try to fund the transaction (I want to subtract fee from the change output for some reasons):
e2-cli fundrawtransaction $RTX &quot;{\&quot;changeAddress\&quot;:\&quot;$CHANGE\&quot;,\&quot;changePosition\&quot;:0,\&quot;subtractFeeFromOutputs\&quot;:[0],\&quot;includeWatching\&quot;:true}&quot;
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:
{
  &quot;inputs&quot;: [
  ],
  &quot;next&quot;: &quot;extractor&quot;,
  &quot;estimated_vsize&quot;: 78,
  &quot;estimated_feerate&quot;: 0.00000000,
  &quot;fee&quot;: {
    &quot;bitcoin&quot;: 0.00000000,
    &quot;ceefd76de1b71c2bed3de04481826287a80babb6e1f6c9feca14e57597742d74&quot;: -0.50000000
  }
}

What am I missing here? I didn't put the &quot;fee&quot; key when I did createrawtransaction, as far as I can tell, so why did my asset X output became a fee output?
Ok it turned out I was a bit confused about the way fees and change is handled here. Here are the commands that worked for me:

createrawtransaction &quot;[]&quot; &quot;[{\&quot;$UADDR\&quot;:1.2},{\&quot;$UCHANGE\&quot;:1.8}]&quot; 0 false &quot;{\&quot;$UADDR\&quot;:\&quot;$ASSET\&quot;,\&quot;$UCHANGE\&quot;:\&quot;$ASSET\&quot;}&quot;
fundrawtransaction $RTX &quot;{\&quot;changeAddress\&quot;:\&quot;$UFEECHANGE\&quot;,\&quot;includeWatching\&quot;:true}&quot;
blindrawtransaction $RTX
and then on the signing side signrawtransactionwithwallet $RTX

Some comments:

the change address given in the fundrawtransaction command is actually used for the change of the fees paid in L-BTC, since here fees are explicit, not like in Bitcoin. That's why I added an explicit change address and amount for the asset I was sending.
I used unconfidential addresses to create the raw transaction
includeWatching is not implicitly true like in a bitcoin watch-only wallet
the tx worked, it was broadcasted and accepted by the network, but there's still something wrong with the blinding, the destination output has not been blinded, and on the other hand I messed up the change of the fee, it seems I can't unblind it myself