Replies: 2 comments 3 replies
-
Creating address from public key is a simple hash, it has nothing to do with mnemonic or derivation path. |
Beta Was this translation helpful? Give feedback.
3 replies
-
pubKeyHashData := C.TWHashSHA256RIPEMD(C.TWPublicKeyData(pub))
redeemScriptBytes := []byte{}
redeemScriptBytes = append(redeemScriptBytes, 0x00, 0x00)
redeemScriptBytes[1] = 0x14
redeemScriptBytes = append(redeemScriptBytes, TWDataGoBytes(pubKeyHashData)...)
addrBytes := C.TWHashSHA256RIPEMD(TWDataCreateWithGoBytes(redeemScriptBytes))
data := []byte{}
data = append(data, 0x05)
data = append(data, TWDataGoBytes(addrBytes)...)
p2shp2wpkhAddr := C.TWBitcoinAddressCreateWithData(TWDataCreateWithGoBytes(data)) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
3tbraden
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
TWBitcoinAddressCreateWithPublicKey
withTWCoinTypeP2shPrefix(TWCoinTypeBitcoin)
does not product the correct address. With public key03b54d899b0760164100601571f783a99a8d456975a70303d14a4828882a118de9
, I got3FNHEJmrBdBDpQn1PfjB1qhsXWJUeygQzP
instead of3GMJNpE5Xj44YEJbNskyHLVQkd8DV7GDCE
.To Reproduce
Expected behavior
I used the above code to test BIP49 address generation, public key from the mnemonic
left already pipe
and derivation pathm/49'/0'/0'/0/0
, and expected address to be3GMJNpE5Xj44YEJbNskyHLVQkd8DV7GDCE
as verified from iancoleman.io and electrum wallet.Screenshots
![image](https://user-images.githubusercontent.com/19732240/112263710-b68db000-8caa-11eb-957c-2b6d6b48d021.png)
Beta Was this translation helpful? Give feedback.
All reactions