refactored BtcEncode