This commit is contained in:
timlucmiptev 2020-10-04 16:07:07 +03:00 committed by ixv
parent 831422afb4
commit f55908c87e
2 changed files with 29 additions and 0 deletions

View File

@ -42,6 +42,19 @@ The below requires norsyr's fix to `decompress-point` in order to work.
=bip173 -build-file %/lib/bip173/hoon
```
### BTC pubkey -> address hashing
Uses the example data here:
https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
That one starts with pubkey below. The following runs it through sha256 and ripemd160 to yield the hash:
`0xf54a.5851.e937.2b87.810a.8e60.cdd2.e7cf.d80b.6e31`
Use `@uc` to make the Hash-160 into a BTC P2PKH address
```
=pubkey 0x2.5086.3ad6.4a87.ae8a.2fe8.3c1a.f1a8.403c.b53f.53e4.86d8.511d.ad8a.0488.7e5b.2352
(p2pkh:bip173 pubkey)
`@uc`(p2pkh:bip173 pubkey)
```
## Deprecated: `btc-address` Child Derivations
**Test xpub parsing**
@ -63,3 +76,10 @@ The below requires norsyr's fix to `decompress-point` in order to work.
```
(bind px |=(px=parsed-xpub:btca (compute-i:btca px 1)))
```
0xf54a.5851.e937.2b87.810a.8e60.cdd2.e7cf.d80b.6e31
0x2.b092.22c4.98c3.ab97.ce2b.6c4d.e68f.07d4.b031.589c.4d6b.bd31.7791.068f.7347.5201
0x2.5086.3ad6.4a87.ae8a.2fe8.3c1a.f1a8.403c.b53f.53e4.86d8.511d.ad8a.0488.7e5b.2352

View File

@ -1,7 +1,9 @@
|%
+$ address ?([@uc [%bech32 @t]])
+$ decoded-bech32 [hrp=tape data=(list @) checksum=(list @)]
::
++ charset "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
::
++ polymod
|= values=(list @)
=/ gen=(list @ux)
@ -70,6 +72,13 @@
=/ checksum-pos (sub (lent data-and-checksum) 6)
`[hrp (scag checksum-pos data-and-checksum) (slag checksum-pos data-and-checksum)]
::
++ hash-160
|= pubkey=@ux
^- @ux
=/ sha (swp 3 (shax (swp 3 pubkey)))
%- ripemd-160:ripemd:crypto
[(met 3 sha) sha]
::
++ decode-segwit
|= segwit=tape
^- (unit [witver=@ witprog=@ux])