Skip to content

Commit

Permalink
TxToUniv: check ptxoutwit->vchRangeproof.size() before secp256k1_rang…
Browse files Browse the repository at this point in the history
…eproof_info()

Otherwise,

```e1-cli sendrawtransaction 02000000010161616161616161616161616161616161616161616161616161616161616161610000000000ffffffff0100000000000000000000010100000000
```
results in
```

#0  0x00007ffff65686ab in raise () from /lib64/libc.so.6
#1  0x00007ffff6551539 in abort () from /lib64/libc.so.6
ElementsProject#2  0x0000555555e199bb in secp256k1_default_illegal_callback_fn (str=<optimized out>, data=<optimized out>) at src/secp256k1.c:52
ElementsProject#3  0x0000555555e2b8fc in secp256k1_callback_call (cb=<optimized out>, cb=<optimized out>, text=0x555555f35057 "proof != NULL")
    at src/util.h:24
ElementsProject#4  secp256k1_rangeproof_info (ctx=<optimized out>, exp=<optimized out>, mantissa=<optimized out>, min_value=<optimized out>, 
    max_value=<optimized out>, proof=<optimized out>, plen=0) at src/modules/rangeproof/main_impl.h:230
ElementsProject#5  0x0000555555cb2768 in TxToUniv (tx=..., hashBlock=..., entry=..., include_hex=false, serialize_flags=0) at core_write.cpp:330
ElementsProject#6  0x00005555557c3f42 in decoderawtransaction (request=...) at rpc/rawtransaction.cpp:684
```

This is because the transaction contains nValue in txout that have empty commitment. It is considered 'not explicit', but it is also not confidential.

To me, it seems that empty nValue (empty commitment) is not valid at all, and probably this should have been caught in the transaction decoding code.
  • Loading branch information
dgpv committed Jul 30, 2019
1 parent 065401b commit b15a971
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
uint64_t minv;
uint64_t maxv;
const CTxOutWitness* ptxoutwit = tx.witness.vtxoutwit.size() <= i? NULL: &tx.witness.vtxoutwit[i];
if (ptxoutwit && secp256k1_rangeproof_info(secp256k1_blind_context, &exp, &mantissa, &minv, &maxv, &ptxoutwit->vchRangeproof[0], ptxoutwit->vchRangeproof.size())) {
if (ptxoutwit && ptxoutwit->vchRangeproof.size() && secp256k1_rangeproof_info(secp256k1_blind_context, &exp, &mantissa, &minv, &maxv, &ptxoutwit->vchRangeproof[0], ptxoutwit->vchRangeproof.size())) {
if (exp == -1) {
out.pushKV("value", ValueFromAmount((CAmount)minv));
} else {
Expand Down

0 comments on commit b15a971

Please sign in to comment.