CMEONE / chia-utils

A set of JavaScript utilities to facilitate conversions for the Chia network
GNU Affero General Public License v3.0
20 stars 9 forks source link

get_coin_info bug #3

Closed xw332 closed 3 years ago

xw332 commented 3 years ago

var amount = 0.5994 var parent_coin_info = '0x5db7892bd03b7ddc6368646250d7bafeff19bf64517c1b901d32ce3bd8ce3e7d' var puzzle_hash = '0xc2f1ff148e091196c8cf415db67f8381ab0d91b5b71ee7841a1bbd96b2923f44'

get_coin_info result is 0xc8fa5267c1cff10a860e715fedf0d423a6399cf4d7b1cfe398e9d737c66bb302, different from site:

https://www.chiaexplorer.com/blockchain/coin/0x226bee197e358e60c25d907d5ad2db0c4508861a1d66b8438602bb31ac43aa0c

the amountHex result is '8b8f062a00', but the right result is '008b8f062a00'

I use this code to fix

  const fixPreLength = (num, len) => (Array(len).join(0) + num).slice(-len)
  let amountHex = amount.toString(16)
  const byte_count = (amount.toString(2).length + 8) >> 3
  amountHex = fixPreLength(amountHex, byte_count * 2)

so, how the get_coin_info function to do with this bug?

CMEONE commented 3 years ago

Fixed in v1.0.4.

CMEONE commented 3 years ago

@xw332 Please verify that this operation works and reopen if there are any further issues.