ElementsProject / ElementsProject/elements
analyzepsbt causes elementsd to crash with assertion when given a funded psbt
- Dominant language
- C++
- Stars
- 1.2k
- Forks
- 417
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 15
Description
I created a funded psbt with walletcreatefundedpsbt like so:
```
elements-cli walletcreatefundedpsbt [] "[{\"AzpxinPHtswVettidEhUXDeWjo3msP1A9Je5LFhQaQn5Ppf8owJCpDwjiQ6EF9YqXBAMU7BA4MKaJbba\": 0.005}]"
```
Got back this base64:
```
cHNldP8BAOYCAAAAAAEsWBoeyDkflmXpi5jQkPHg8wZfwKEaW7vPsuXDNLDczQAAAAAA/f///wMBIw9PXUt8b6hFgG7k9ncTRZ4baejmD87i5JQMeg1d4bIBAAAAAAAHoSAAF6kUjgi2GF+HLOU/2sdtm1pJCKgfNV6HASMPT11LfG+oRYBu5PZ3E0WeG2no5g/O4uSUDHoNXeGyAQAAAAAACHC9ABepFP7cZ+8ME60uxggvruycSy4fvY1shwEjD09dS3xvqEWAbuT2dxNFnhtp6OYPzuLklAx6DV3hsgEAAAAAAAATqAAAAAAAAAABAXsKPx/usbyE4kTa7LxW/ustPjOUm4y0RAdXlL2330fTOhsIGlU1e+InW2iHtZnIA709D+ay4/oy2Ger0lFNE+IkyDkCBCq2g4qvR9U/4gLMIG+uVotIw29sMt0BRMfcEHElF74XqRQjeWVHHqxvbRA+bnGx6j4Ewl+7dYcBBBYAFNkz1CQWGddFqLmKfsaOndWDTOywC/wIZWxlbWVudHMACIUlEAAAAAAAC/wIZWxlbWVudHMBIKi3jTE2NLFR6K05mWuarF3vcKNiQGLfSurDj8GPMtuUC/wIZWxlbWVudHMCICMPT11LfG+oRYBu5PZ3E0WeG2no5g/O4uSUDHoNXeGyC/wIZWxlbWVudHMDIIvcBGIPK8XIHNh4WGA/leVebfTHb4OK/YEsaaqbCMwJAAEAFgAU+E22AnLTPjcKxlOInxYPMbsDprIL/AhlbGVtZW50cwYhA/u/+l8BhVgjNzMgA6lpYNSZLt9G5m/xd7gHDZmFTkifAAEAFgAUKwsM7lZOHjLB5WkrWBaKAKhllekL/AhlbGVtZW50cwYhAzId3EdeAMUNL/BjBtCw8nNKbObEEFZzsDp0HuVwLGzGAAA=
```
which decodes to:
```
{
"tx": {
"txid": "e56fb4eccceb57cb2bcef66584e7013123f8abac1ab00853b8b7469be13f3110",
"hash": "e56fb4eccceb57cb2bcef66584e7013123f8abac1ab00853b8b7469be13f3110",
"wtxid": "e56fb4eccceb57cb2bcef66584e7013123f8abac1ab00853b8b7469be13f3110",
"withash": "ab3393f4fb64685a4de07ac89c6903d6a0ba107c87fff33c9a981a7590bae48e",
"version": 2,
"size": 230,
"vsize": 230,
"weight": 920,
"locktime": 0,
"vin": [
{
"txid": "cddcb034c3e5b2cfbb5b1aa1c05f06f3e0f190d0988be965961f39c81e1a582c",
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""
},
"is_pegin": false,
"sequence": 4294967293
}
],
"vout": [
{
"value": 0.00500000,
"asset": "b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23",
"commitmentnonce": "",
"commitmentnonce_fully_valid": false,
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 8e08b6185f872ce53fdac76d9b5a4908a81f355e OP_EQUAL",
"hex": "a9148e08b6185f872ce53fdac76d9b5a4908a81f355e87",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"XQJFEf51iwod6AAhqGtSHPKJP7x2vSrbXx"
]
}
},
{
"value": 0.00553149,
"asset": "b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23",
"commitmentnonce": "",
"commitmentnonce_fully_valid": false,
"n": 1,
"scriptPubKey": {
"asm": "OP_HASH160 fedc67ef0c13ad2ec6082faeec9c4b2e1fbd8d6c OP_EQUAL",
"hex": "a914fedc67ef0c13ad2ec6082faeec9c4b2e1fbd8d6c87",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"XaapWwrT7qG7QetGLEQtTdw5Q1X5Dc8eMe"
]
}
},
{
"value": 0.00005032,
"asset": "b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23",
"commitmentnonce": "",
"commitmentnonce_fully_valid": false,
"n": 2,
"scriptPubKey": {
"asm": "",
"hex": "",
"type": "fee"
}
}
]
},
"fees": {
"bitcoin": 0.00005032
},
"unknown": {
},
"inputs": [
{
"witness_utxo": {
"amountcommitment": "081a55357be2275b6887b599c803bd3d0fe6b2e3fa32d867abd2514d13e224c839",
"scriptPubKey": {
"asm": "OP_HASH160 237965471eac6f6d103e6e71b1ea3e04c25fbb75 OP_EQUAL",
"hex": "a914237965471eac6f6d103e6e71b1ea3e04c25fbb7587",
"type": "scripthash",
"address": "XEaovaFzmPaRpTkhmpjymBafxNHy8zA2P9"
}
},
"redeem_script": {
"asm": "0 d933d4241619d745a8b98a7ec68e9dd5834cecb0",
"hex": "0014d933d4241619d745a8b98a7ec68e9dd5834cecb0",
"type": "witness_v0_keyhash"
},
"value": 0.01058181,
"value_blinding_factor": "94db328fc18fc3ea4adf624062a370ef5dac9a6b9939ade851b13436318db7a8",
"asset": "b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23",
"asset_blinding_factor": "09cc089baa692c81fd8a836fc7f46d5ee5953f605878d81cc8c52b0f6204dc8b"
}
],
"outputs": [
{
"redeem_script": {
"asm": "0 f84db60272d33e370ac653889f160f31bb03a6b2",
"hex": "0014f84db60272d33e370ac653889f160f31bb03a6b2",
"type": "witness_v0_keyhash"
},
"blinding_pubkey": "03fbbffa5f0185582337332003a96960d4992edf46e66ff177b8070d99854e489f"
},
{
"redeem_script": {
"asm": "0 2b0b0cee564e1e32c1e5692b58168a00a86595e9",
"hex": "00142b0b0cee564e1e32c1e5692b58168a00a86595e9",
"type": "witness_v0_keyhash"
},
"blinding_pubkey": "03321ddc475e00c50d2ff06306d0b0f2734a6ce6c4105673b03a741ee5702c6cc6"
},
{
}
]
}
```
Passing the base 64 to analyzepsbt causes my daemon to crash:
```
elements-cli analyzepsbt cHNldP8BAOYCAAAAAAEsWBoeyDkflmXpi5jQkPHg8wZfwKEaW7vPsuXDNLDczQAAAAAA/f///wMBIw9PXUt8b6hFgG7k9ncTRZ4baejmD87i5JQMeg1d4bIBAAAAAAAHoSAAF6kUjgi2GF+HLOU/2sdtm1pJCKgfNV6HASMPT11LfG+oRYBu5PZ3E0WeG2no5g/O4uSUDHoNXeGyAQAAAAAACHC9ABepFP7cZ+8ME60uxggvruycSy4fvY1shwEjD09dS3xvqEWAbuT2dxNFnhtp6OYPzuLklAx6DV3hsgEAAAAAAAATqAAAAAAAAAABAXsKPx/usbyE4kTa7LxW/ustPjOUm4y0RAdXlL2330fTOhsIGlU1e+InW2iHtZnIA709D+ay4/oy2Ger0lFNE+IkyDkCBCq2g4qvR9U/4gLMIG+uVotIw29sMt0BRMfcEHElF74XqRQjeWVHHqxvbRA+bnGx6j4Ewl+7dYcBBBYAFNkz1CQWGddFqLmKfsaOndWDTOywC/wIZWxlbWVudHMACIUlEAAAAAAAC/wIZWxlbWVudHMBIKi3jTE2NLFR6K05mWuarF3vcKNiQGLfSurDj8GPMtuUC/wIZWxlbWVudHMCICMPT11LfG+oRYBu5PZ3E0WeG2no5g/O4uSUDHoNXeGyC/wIZWxlbWVudHMDIIvcBGIPK8XIHNh4WGA/leVebfTHb4OK/YEsaaqbCMwJAAEAFgAU+E22AnLTPjcKxlOInxYPMbsDprIL/AhlbGVtZW50cwYhA/u/+l8BhVgjNzMgA6lpYNSZLt9G5m/xd7gHDZmFTkifAAEAFgAUKwsM7lZOHjLB5WkrWBaKAKhllekL/AhlbGVtZW50cwYhAzId3EdeAMUNL/BjBtCw8nNKbObEEFZzsDp0HuVwLGzGAAA=
error: Could not connect to the server 127.0.0.1:18882 (error code 1 - "EOF reached")
Make sure the daemon server is running and that you are connecting to the correct RPC port.
```
With this in the debug.log:
```
elementsd: ./primitives/confidential.h:140: CAmount CConfidentialValue::GetAmount() const: Assertion `IsExplicit()' failed.
```
Contributor guide
Research direction
Reproduce the crash with the supplied funded PSBT using the analyzepsbt command, then inspect primitives/confidential.h around CConfidentialValue::GetAmount() at line 140 and trace how analyzepsbt handles the transaction data. Done means analyzepsbt no longer terminates elementsd with the IsExplicit() assertion when given this PSBT.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- blockchain
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100