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": [

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?


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.