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
Uh oh!
There was an error while loading. Please reload this page.
-
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

Beta Was this translation helpful? Give feedback.
All reactions