Skip to content

Commit 7f8794d

Browse files
thephezclaude
andcommitted
feat(dip-18): use type bytes 0xb0/0x80 for P2PKH/P2SH
Change type bytes to produce distinct address prefixes: - P2PKH: 0xb0 -> addresses start with "k" - P2SH: 0x80 -> addresses start with "s" Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 7073bf1 commit 7f8794d

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

dip-0018.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Encoding a Dash Platform address uses the bech32m format defined in [BIP-350](ht
6161
Given:
6262

6363
* `hrp`: the network human-readable prefix (e.g., `evo`, `tevo`)
64-
* `type_byte`: `0x00` for P2PKH or `0x01` for P2SH
64+
* `type_byte`: `0xb0` for P2PKH or `0x80` for P2SH
6565
* `hash160`: a 20-byte `HASH160(pubkey or script)` value
6666

6767
The address MUST be encoded as follows:
@@ -77,7 +77,7 @@ Decoders MUST reverse these steps and MUST verify:
7777
* Checksum validity (per [BIP-350](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki#appendix-checksum-design--properties)),
7878
* HRP correctness for the target network,
7979
* Data-part length requirements,
80-
* The type byte is either `0x00` or `0x01`.
80+
* The type byte is either `0xb0` or `0x80`.
8181

8282
#### Structure
8383

@@ -89,7 +89,7 @@ All Platform addresses are encoded as:
8989

9090
* `<HRP>` is network-specific (see table).
9191
* `<data-part>` contains:
92-
* one type byte (`0x00` P2PKH, `0x01` P2SH), followed by
92+
* one type byte (`0xb0` P2PKH, `0x80` P2SH), followed by
9393
* 20-byte HASH160 payload encoded as 5-bit groups via bech32 rules.
9494

9595
The checksum MUST be calculated using the [bech32m algorithm as defined in BIP-350](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki#bech32m).
@@ -122,8 +122,8 @@ Type byte meaning:
122122

123123
| Address Type | Type byte |
124124
| -------------- | --------- |
125-
| Platform P2PKH | `0x00` |
126-
| Platform P2SH | `0x01` |
125+
| Platform P2PKH | `0xb0` |
126+
| Platform P2SH | `0x80` |
127127

128128
### Validation
129129

@@ -133,7 +133,7 @@ A Platform address is valid if:
133133
2. HRP matches expected network.
134134
3. bech32m checksum verifies.
135135
4. Payload decodes to exactly 21 bytes.
136-
5. `payload[0]` is `0x00` or `0x01`.
136+
5. `payload[0]` is `0xb0` or `0x80`.
137137

138138
Wallets MUST reject Platform addresses when constructing Dash Core chain scripts and SHOULD present a clear warning if a user attempts to mix layers.
139139

@@ -144,7 +144,7 @@ Wallets MUST reject Platform addresses when constructing Dash Core chain scripts
144144
* Wallets MUST treat HRP as the network selector.
145145
* Software wallets SHOULD label Platform balances separately from Core chain balances and SHOULD avoid auto-pasting Platform addresses into Core chain contexts.
146146
* Wallets SHOULD derive payloads via [DIP-17](dip-0017.md) and then encode using these rules; no alternative prefixes are allowed.
147-
* Hardware wallets MUST validate the HRP to confirm network identity and MUST enforce the type byte (`0x00` or `0x01`). Devices MUST display a user-facing descriptor: “Dash Platform address” for P2PKH and “Dash Platform script address” for P2SH.
147+
* Hardware wallets MUST validate the HRP to confirm network identity and MUST enforce the type byte (`0xb0` or `0x80`). Devices MUST display a user-facing descriptor: “Dash Platform address” for P2PKH and “Dash Platform script address” for P2SH.
148148

149149
## Rationale
150150

@@ -171,7 +171,7 @@ function encode_platform_address(hash160, type, network):
171171
if len(hash160) != 20:
172172
error("invalid hash160 length")
173173
174-
type_byte = 0x00 if type=="p2pkh" else 0x01 if type=="p2sh" else error()
174+
type_byte = 0xb0 if type=="p2pkh" else 0x80 if type=="p2sh" else error()
175175
176176
hrp = {
177177
"mainnet": "evo",
@@ -209,9 +209,9 @@ function decode_platform_address(addr):
209209
type_byte = payload[0]
210210
hash160 = payload[1:21]
211211
212-
if type_byte == 0x00:
212+
if type_byte == 0xb0:
213213
addr_type = "p2pkh"
214-
else if type_byte == 0x01:
214+
else if type_byte == 0x80:
215215
addr_type = "p2sh"
216216
else:
217217
error("unknown type byte")
@@ -243,16 +243,16 @@ The HASH160 payloads in the following tables are derived from the mnemonic and p
243243

244244
| Vector | Payload (HASH160) | Mainnet (`evo`) | Testnet (`tevo`) |
245245
| ------ | ------------------------------------------ | ------------------------------------------------ | ------------------------------------------------- |
246-
| 1 | `f7da0a2b5cbd4ff6bb2c4d89b67d2f3ffeec0525` | `evo1qrma5z3ttj75la4m93xcndna9ullamq9y57vzaqm` | `tevo1qrma5z3ttj75la4m93xcndna9ullamq9y5ch5x7d` |
247-
| 2 | `a5ff0046217fd1c7d238e3e146cc5bfd90832a7e` | `evo1qzjl7qzxy9lar37j8r37z3kvt07epqe20c30csp9` | `tevo1qzjl7qzxy9lar37j8r37z3kvt07epqe20ch5wtln` |
248-
| 3 | `6d92674fd64472a3dfcfc3ebcfed7382bf699d7b` | `evo1qpkeye606ez89g7lelp7hnldwwpt76va0vkmt0fv` | `tevo1qpkeye606ez89g7lelp7hnldwwpt76va0vsqa5h6` |
246+
| 1 | `f7da0a2b5cbd4ff6bb2c4d89b67d2f3ffeec0525` | `evo1krma5z3ttj75la4m93xcndna9ullamq9y59dj9x7` | `tevo1krma5z3ttj75la4m93xcndna9ullamq9y5rky7cg` |
247+
| 2 | `a5ff0046217fd1c7d238e3e146cc5bfd90832a7e` | `evo1kzjl7qzxy9lar37j8r37z3kvt07epqe20c2wgg8q` | `tevo1kzjl7qzxy9lar37j8r37z3kvt07epqe20cv47nek` |
248+
| 3 | `6d92674fd64472a3dfcfc3ebcfed7382bf699d7b` | `evo1kpkeye606ez89g7lelp7hnldwwpt76va0vd6mh0f` | `tevo1kpkeye606ez89g7lelp7hnldwwpt76va0vtpdv3l` |
249249

250250
### P2SH example
251251

252252
Payload: `43fa183cf3fb6e9e7dc62b692aeb4fc8d8045636`
253253

254-
* Mainnet: `evo1q9pl5xpu70aka8nacc4kj2htflydspzkxccyfcmc`
255-
* Testnet: `tevo1q9pl5xpu70aka8nacc4kj2htflydspzkxc7llr9w`
254+
* Mainnet: `evo1sppl5xpu70aka8nacc4kj2htflydspzkxctaevg5`
255+
* Testnet: `tevo1sppl5xpu70aka8nacc4kj2htflydspzkxcdx0hkz`
256256

257257
## Copyright
258258

dip-0018/bech32.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ def convertbits(data, frombits, tobits, pad=True):
155155
HRP_TO_NETWORK = {v: k for k, v in NETWORK_TO_HRP.items()}
156156

157157
TYPE_TO_BYTE = {
158-
"p2pkh": 0x00,
159-
"p2sh": 0x01,
158+
"p2pkh": 0xb0,
159+
"p2sh": 0x80,
160160
}
161161

162162
BYTE_TO_TYPE = {v: k for k, v in TYPE_TO_BYTE.items()}
@@ -309,34 +309,34 @@ def format_path(path: list[int]) -> str:
309309
"6bca392f43453b7bc33a9532b69221ce74906a8815281637e0c9d0bee35361fe",
310310
"03de102ed1fc43cbdb16af02e294945ffaed8e0595d3072f4c592ae80816e6859e",
311311
"f7da0a2b5cbd4ff6bb2c4d89b67d2f3ffeec0525",
312-
"evo1qrma5z3ttj75la4m93xcndna9ullamq9y57vzaqm",
313-
"tevo1qrma5z3ttj75la4m93xcndna9ullamq9y5ch5x7d",
312+
"evo1krma5z3ttj75la4m93xcndna9ullamq9y59dj9x7",
313+
"tevo1krma5z3ttj75la4m93xcndna9ullamq9y5rky7cg",
314314
),
315315
# Vector 2: m/9'/5'/17'/0'/0'/1
316316
(
317317
[9 + H, 5 + H, 17 + H, 0 + H, 0 + H, 1],
318318
"eef58ce73383f63d5062f281ed0c1e192693c170fbc0049662a73e48a1981523",
319319
"02269ff766fcd04184bc314f5385a04498df215ce1e7193cec9a607f69bc8954da",
320320
"a5ff0046217fd1c7d238e3e146cc5bfd90832a7e",
321-
"evo1qzjl7qzxy9lar37j8r37z3kvt07epqe20c30csp9",
322-
"tevo1qzjl7qzxy9lar37j8r37z3kvt07epqe20ch5wtln",
321+
"evo1kzjl7qzxy9lar37j8r37z3kvt07epqe20c2wgg8q",
322+
"tevo1kzjl7qzxy9lar37j8r37z3kvt07epqe20cv47nek",
323323
),
324324
# Vector 3: m/9'/5'/17'/0'/1'/0 (key_class' = 1')
325325
(
326326
[9 + H, 5 + H, 17 + H, 0 + H, 1 + H, 0],
327327
"cc05b4389712a2e724566914c256217685d781503d7cc05af6642e60260830db",
328328
"0317a3ed70c141cffafe00fa8bf458cec119f6fc039a7ba9a6b7303dc65b27bed3",
329329
"6d92674fd64472a3dfcfc3ebcfed7382bf699d7b",
330-
"evo1qpkeye606ez89g7lelp7hnldwwpt76va0vkmt0fv",
331-
"tevo1qpkeye606ez89g7lelp7hnldwwpt76va0vsqa5h6",
330+
"evo1kpkeye606ez89g7lelp7hnldwwpt76va0vd6mh0f",
331+
"tevo1kpkeye606ez89g7lelp7hnldwwpt76va0vtpdv3l",
332332
),
333333
]
334334

335335
# DIP-18 P2SH vector (address encoding only, no derivation path)
336336
P2SH_VECTOR = (
337337
"43fa183cf3fb6e9e7dc62b692aeb4fc8d8045636",
338-
"evo1q9pl5xpu70aka8nacc4kj2htflydspzkxccyfcmc",
339-
"tevo1q9pl5xpu70aka8nacc4kj2htflydspzkxc7llr9w",
338+
"evo1sppl5xpu70aka8nacc4kj2htflydspzkxctaevg5",
339+
"tevo1sppl5xpu70aka8nacc4kj2htflydspzkxcdx0hkz",
340340
)
341341

342342

0 commit comments

Comments
 (0)