lbryio / lbrycrd

The blockchain that provides the digital content namespace for the LBRY protocol
https://lbry.com
MIT License
2.57k stars 178 forks source link

Claim name returned is strange #172

Closed mirgee closed 6 years ago

mirgee commented 6 years ago

Fixing issue #119 .

In bitcoin, small stack pushes are treated as integers when converting scripts to asm. For our use case, it is more sensible to print all pushes as hex strings.

Using tx hex string from the issue thread, tested with

./lbrycrd-cli decodescript b504636174734cdc080110011a7808011230080410011a084d616361726f6e6922002a003214416c6c207269676874732072657365727665642e38004a0052005a001a42080110011a30add80aaf02559ba09853636a0658c42b727cb5bb4ba8acedb4b7fe656065a47a31878dbf9912135ddb9e13806cc1479d220a696d6167652f6a7065672a5c080110031a404180cc0fa4d3839ee29cca866baed25fafb43fca1eb3b608ee889d351d3573d042c7b83e2e643db0d8e062a04e6e9ae6b90540a2f95fe28638d0f18af4361a1c2214f73de93f4299fb32c32f949e02198a8e91101abd6d7576a914be16e4b0f9bd8f6d47d02b3a887049c36d3b84cb88ac

which gives

{
  "asm": "OP_CLAIM_NAME 63617473 080110011a780801123...",
   ...
}

and this is the expected behavior, since 63617473 is hex for cats.

I will follow with further testing or unit tests if necessary.

BrannonKing commented 6 years ago

Are you able to add a unit test for this scenario?

lbrynaut commented 6 years ago

@BrannonKing Has it been determined that this "fix" is needed?

kaykurokawa commented 6 years ago

I was thinking that perhaps this might be too broad of a fix, and it would be better to detect if a script contains a claim OP code and handle it differently, rather than applying this fix to all scripts. Some application might depend on this particular behavior for decoderawtransaction and we might end up breaking it.. although I don't know of any application that does.

lbrynaut commented 6 years ago

@kaykurokawa Sounds reasonable. I think we should revisit this after upstream changes because 1) It's not urgent, and 2) Arguably it's not broken (although perhaps not easily understood).