bitcoin 地址的几种加密方式

draft: false date: 2018-01-10 21:31:35 cover: /images/avatar.jpeg tags: - bigzhu preview:


btcd rpc client 里对 address 有这样一段代码

	switch len(decoded) {
	case ripemd160.Size: // P2PKH or P2SH
		isP2PKH := chaincfg.IsPubKeyHashAddrID(netID)
		isP2SH := chaincfg.IsScriptHashAddrID(netID)
		switch hash160 := decoded; {
		case isP2PKH && isP2SH:
			return nil, ErrAddressCollision
		case isP2PKH:
			return newAddressPubKeyHash(hash160, netID)
		case isP2SH:
			return newAddressScriptHashFromHash(hash160, netID)
		default:
			return nil, ErrUnknownAddressType
		}

会对地址做几种检查, 可以看这里

LMC 的 newaddress 报错了:

=== RUN   TestAddress
2018/01/10 21:29:58 address.go:183: LbXpfonSpPkoNu6FifJaoxLp9xXq1pWBKk
2018/01/10 21:29:58 wallet_test.go:19:
--- FAIL: TestAddress (0.67s)
        wallet_test.go:17: unknown address type
=== RUN   TestAddressBath
2018/01/10 21:29:59 address.go:183: mnTJn97Exq9huYU3Qseq3yMbwNP3PVNm6h
2018/01/10 21:29:59 address.go:183: mvMy3uFYpjYdRc8pwzhFmm9bngRCdeCuZz
2018/01/10 21:30:00 address.go:183: mw2GV6tCFSzd1NzmAmFWSg1bZwjoxBEhJQ
2018/01/10 21:30:00 address.go:183: mmQ2Bw4mx8WbfNmwo8tKL6TRM5DC5pWMwd
2018/01/10 21:30:01 address.go:183: mzrvKE1dvguR6NL6q3D5pxyqL1co6krkwA
2018/01/10 21:30:01 address.go:183: n2SiX7gJDUmTgKvAoWH83FvDCuZM2pudqK
2018/01/10 21:30:02 address.go:183: mkkqhDLAyxuNXNWCdpMuTqDENRndsFHub9
2018/01/10 21:30:02 address.go:183: n4maswhNzrWEV1DctURgnUSUQ3476u14nv
2018/01/10 21:30:02 address.go:183: mrJo7nwNHVNxj2GoY3rhjPQsuub7P1Vj2s
2018/01/10 21:30:03 address.go:183: mwi3ASsRDAyJkaopRNq5qFzKHJXeKNV9RF
--- PASS: TestAddressBath (4.89s)
FAIL
exit status 1

说是用的 P2PKH P2PK 和 P2SH

http://zqsmm.qiniucdn.com/data/20170901142840/index.html 说的更清楚一些

得到的地址是以 L 开头的

P2SH

http://www.8btc.com/p2sh 对 P2SH 有说明, 按理说取到的地址并没有以 3 开头, 应该不是 P2SH 才对