elements icon indicating copy to clipboard operation
elements copied to clipboard

amountcommitment or valuecommitment

Open carnhofdaki opened this issue 11 months ago • 3 comments

In listunspent RPC there is ammountcommitment:

$ elements-cli -rpcwallet=real listunspent
[
  {
    "txid": "2ef46ad30a0a002fadb5214c1c746d361a4adfdde1d47a3a6bd77e29229c3151",
    "vout": 1,
    "address": "H4iZbR67ywSKvpRgYqGSuqfmAtJLxgiTQ4",
    "label": "c2",
    "redeemScript": "001489a5ca6bfa43e3e60bc8545fd448262bc29cd587",
    "scriptPubKey": "a914ec395de045564b4851f188d8991b3a11ac7408db87",
    "amount": 0.00000001,
    "assetcommitment": "0b80363e4a0f0332e9a6cd338eed1247eb59242e047b8c2dacdbc9590c609484c6",
    "asset": "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d",
    "amountcommitment": "09ff0377d7f474048fff55c41bfa369624db069f9b30a7e574ab49d335c3a0cbee",
    "amountblinder": "258f64b23ae417a63bf8167728aeecb95889464b1af9b8d1c48ba29670e58933",
    "assetblinder": "75082cc0e11be120913e7f5b8ca74b2019af64812488dfd858a47a3e8db39db8",
    "confirmations": 299187,
    "spendable": true,
    "solvable": true,
    "desc": "sh(wpkh([8baa2a22/0'/0'/1213']0274c2569ed3907d21b5b4850daf6a324a402c96e9b4fb67f5bb72f35ce38ce84d))#vs2k8pq9",
    "safe": true
  }
]

But in gettxout RPC output the same is written as valuecommitment:

$ elements-cli -rpcwallet=real gettxout 2ef46ad30a0a002fadb5214c1c746d361a4adfdde1d47a3a6bd77e29229c3151 1
{
  "bestblock": "9fd47ccb007675fc1fb6147c1d62cd9346f76d9e5edbcf4af17d0fc19813d23a",
  "confirmations": 299189,
  "valuecommitment": "09ff0377d7f474048fff55c41bfa369624db069f9b30a7e574ab49d335c3a0cbee",
  "assetcommitment": "0b80363e4a0f0332e9a6cd338eed1247eb59242e047b8c2dacdbc9590c609484c6",
  "commitmentnonce": "",
  "scriptPubKey": {
    "asm": "OP_HASH160 ec395de045564b4851f188d8991b3a11ac7408db OP_EQUAL",
    "desc": "addr(H4iZbR67ywSKvpRgYqGSuqfmAtJLxgiTQ4)#8v4mh22p",
    "hex": "a914ec395de045564b4851f188d8991b3a11ac7408db87",
    "address": "H4iZbR67ywSKvpRgYqGSuqfmAtJLxgiTQ4",
    "type": "scripthash"
  },
  "coinbase": false
}

Could be something to deprecate in the future version. @delta1

carnhofdaki avatar Jan 29 '25 08:01 carnhofdaki

Thanks for reporting @carnhofdaki

Taking a quick look:

amountcommitment is in RPCs:

  • listunspent
  • scantxoutset
  • decodepsbt

valuecommitment is in RPCs:

Given the number of RPCs that would break by changing valuecommitment to amountcommitment, it seems it would be less breaking to change this in the other direction for the former 3.

As a first step, valuecommitment would be added to those 3 RPCs, with a changelog entry about deprecating amountcommitment, before being removed in a future version.

delta1 avatar Jan 29 '25 08:01 delta1

Maybe it would make more sense to just know about it and leave everything as is?

carnhofdaki avatar Jan 29 '25 11:01 carnhofdaki

We can delay the deprecation step for a while (or forever) -- but for consistency's sake we should update those 3 RPCs to also use the same term as the other ones.

apoelstra avatar Jan 29 '25 14:01 apoelstra