<p>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:</p>
<ol>
<li><code>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;</code></li>
<li><code>fundrawtransaction $RTX &quot;{\&quot;changeAddress\&quot;:\&quot;$UFEECHANGE\&quot;,\&quot;includeWatching\&quot;:true}&quot;</code></li>
<li><code>blindrawtransaction $RTX</code></li>
<li>and then on the signing side <code>signrawtransactionwithwallet $RTX</code></li>
</ol>
<p>Some comments:</p>
<ol>
<li>the change address given in the <code>fundrawtransaction</code> 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.</li>
<li>I used unconfidential addresses to create the raw transaction</li>
<li><code>includeWatching</code> is not implicitly <code>true</code> like in a bitcoin watch-only wallet</li>
<li>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</li>
</ol>

CC BY-SA 4.0
2020-06-18T13:47:48.613Z
2020-06-18T13:47:48.613Z
Sosthène
<p>I know how to create and fund bitcoin transactions using <code>createrawtransaction</code> and <code>fundrawtransaction</code> 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.</p>
<p>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.</p>
<p>I first create a transaction that have only one output of 0.5 asset X:
<code>e2-cli createrawtransaction &quot;[]&quot; &quot;[{\&quot;$ADDR\&quot;:0.5}]&quot; 0 false &quot;{\&quot;$ADDR\&quot;:\&quot;$ASSETX\&quot;}&quot;</code></p>
<p>Now I decode the transaction and I see this:</p>
<pre><code>{
  &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;
        ]
      }
    }
  ]
}
</code></pre>
<p>Then I try to fund the transaction (I want to subtract fee from the change output for some reasons):
<code>e2-cli fundrawtransaction $RTX &quot;{\&quot;changeAddress\&quot;:\&quot;$CHANGE\&quot;,\&quot;changePosition\&quot;:0,\&quot;subtractFeeFromOutputs\&quot;:[0],\&quot;includeWatching\&quot;:true}&quot;</code></p>
<p>And I have this error:</p>
<pre><code>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
</code></pre>
<p>And indeed if I convert it to psbt I see this:</p>
<pre><code>{
  &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
  }
}
</code></pre>
<p>What am I missing here? I didn't put the &quot;fee&quot; key when I did <code>createrawtransaction</code>, as far as I can tell, so why did my asset X output became a fee output?</p>

<json-rpc><createrawtransaction><liquid>
How does `createrawtransaction` and `fundrawtransaction` work with Elements?
Sosthène
# How does `createrawtransaction` and `fundrawtransaction` work with Elements?

(Asked by: username_0 on 2020-06-17)

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?

**Tags:** json-rpc, createrawtransaction, liquid


---

## 1 answers

### Answer by username_0 on 2020-06-18. Score: 1

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:

1. `createrawtransaction "[]" "[{\"$UADDR\":1.2},{\"$UCHANGE\":1.8}]" 0 false "{\"$UADDR\":\"$ASSET\",\"$UCHANGE\":\"$ASSET\"}"`
2. `fundrawtransaction $RTX "{\"changeAddress\":\"$UFEECHANGE\",\"includeWatching\":true}"`
3. `blindrawtransaction $RTX`
4. and then on the signing side `signrawtransactionwithwallet $RTX`

Some comments:

1. 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.
2. I used unconfidential addresses to create the raw transaction
3. `includeWatching` is not implicitly `true` like in a bitcoin watch-only wallet
4. 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


---

