forked from cryptape/omnilock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add missing auth id(0x02~0x05)
migrate PR from: nervosnetwork/ckb-production-scripts#75 including * eos * tron * bitcoin(Support UniSat and OKX wallet) * dogecoin Special feature for btc/etc, now they can display meaningful messages. * BTC(UniSat/OKX) You're signing: CKB (Bitcoin Layer-2) transaction: 0x{sighash_all in hex} * ETH(Metamask) You're signing: CKB transaction: 0x{sighash_all in hex}
1 parent
54541e5
commit bcd9b58
Showing
12 changed files
with
1,611 additions
and
52 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (c) 2014-2018 The Bitcoin Core developers | ||
* Distributed under the MIT software license, see the accompanying | ||
* file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
* | ||
* only used on little endian | ||
*/ | ||
|
||
#ifndef CONVERSION_H | ||
#define CONVERSION_H | ||
|
||
#include <stdint.h> | ||
#include <string.h> | ||
|
||
uint32_t static inline bswap_32(uint32_t x) { | ||
return (((uint32_t)(x)&0xff000000) >> 24) | | ||
(((uint32_t)(x)&0x00ff0000) >> 8) | (((uint32_t)(x)&0x0000ff00) << 8) | | ||
(((uint32_t)(x)&0x000000ff) << 24); | ||
} | ||
|
||
uint64_t static inline bswap_64(uint64_t x) { | ||
return (((uint64_t)(x)&0xff00000000000000ull) >> 56) | | ||
(((uint64_t)(x)&0x00ff000000000000ull) >> 40) | | ||
(((uint64_t)(x)&0x0000ff0000000000ull) >> 24) | | ||
(((uint64_t)(x)&0x000000ff00000000ull) >> 8) | | ||
(((uint64_t)(x)&0x00000000ff000000ull) << 8) | | ||
(((uint64_t)(x)&0x0000000000ff0000ull) << 24) | | ||
(((uint64_t)(x)&0x000000000000ff00ull) << 40) | | ||
(((uint64_t)(x)&0x00000000000000ffull) << 56); | ||
} | ||
|
||
uint32_t static inline le32toh_(uint32_t x) { return x; } | ||
|
||
uint32_t static inline htole32_(uint32_t x) { return x; } | ||
|
||
uint32_t static inline be32toh_(uint32_t x) { return bswap_32(x); } | ||
|
||
uint32_t static inline htobe32_(uint32_t x) { return bswap_32(x); } | ||
|
||
uint64_t static inline le64toh_(uint64_t x) { return x; } | ||
|
||
uint64_t static inline htole64_(uint64_t x) { return x; } | ||
|
||
uint32_t static inline be64toh_(uint64_t x) { return bswap_64(x); } | ||
|
||
uint64_t static inline htobe64_(uint64_t x) { return bswap_64(x); } | ||
|
||
uint32_t static inline ReadLE32(const unsigned char* ptr) { | ||
uint32_t x; | ||
memcpy((char*)&x, ptr, 4); | ||
return le32toh_(x); | ||
} | ||
|
||
void static inline WriteLE32(unsigned char* ptr, uint32_t x) { | ||
uint32_t v = htole32_(x); | ||
memcpy(ptr, (char*)&v, 4); | ||
} | ||
|
||
uint32_t static inline ReadBE32(const unsigned char* ptr) { | ||
uint32_t x; | ||
memcpy((char*)&x, ptr, 4); | ||
return be32toh_(x); | ||
} | ||
|
||
void static inline WriteBE32(unsigned char* ptr, uint32_t x) { | ||
uint32_t v = htobe32_(x); | ||
memcpy(ptr, (char*)&v, 4); | ||
} | ||
|
||
void static inline WriteLE64(unsigned char* ptr, uint64_t x) { | ||
uint64_t v = htole64_(x); | ||
memcpy(ptr, (char*)&v, 8); | ||
} | ||
|
||
uint64_t static inline ReadLE64(const unsigned char* ptr) { | ||
uint64_t x; | ||
memcpy((char*)&x, ptr, 8); | ||
return le64toh_(x); | ||
} | ||
|
||
void static inline WriteBE64(unsigned char* ptr, uint64_t x) { | ||
uint64_t v = htobe64_(x); | ||
memcpy(ptr, (char*)&v, 8); | ||
} | ||
|
||
uint64_t static inline ReadBE64(const unsigned char* ptr) { | ||
uint64_t x; | ||
memcpy((char*)&x, ptr, 8); | ||
return be64toh_(x); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.