horizontalsystems / bitcoin-kit-ios

Comprehensive Bitcoin development library for iOS, implemented on Swift. SPV wallet implementation for Bitcoin, Bitcoin Cash, Litecoin and Dash blockchains. Comprehensive Bitcoin development library for iOS, implemented on Swift. SPV wallet implementation for Bitcoin, Bitcoin Cash, Litecoin and Dash blockchains. Fully compliant with existing standards and BIPs.
https://unstoppable.money
MIT License
242 stars 74 forks source link

Converting addresses #376

Closed tanstaafl856 closed 5 years ago

tanstaafl856 commented 5 years ago

In version 0.4.1 print(bitcoinKit.debugInfo) output 3 addresses for each path index; a [BIP32? 84?] bech32, a [BIP44] legacy, and a [BIP49? 141?] SH(WPKH). In v0.5.1 only the bech32.

Is there a clean way that I am missing to perform the conversion at the BitcoinKit.swift level? Or plans to implement such a conversion? So far everything I have tried at the DataProvider.debugInfo level either does nothing [always prints bech32 regardless of address type indicated] or throws a runtime error.

How about a way to pull an address at a specific derivation path [ex. m/44'/0'/0'/0/17']?

ant013 commented 5 years ago

We use debugInfo just for currently needed information in debug. So we print only segwit address. After implement addressConverterChain for separate converters, BitcoinKit uses segwitConverter and legacy, BitcoinCashKit - CashBech32Converter, Dash - only legacy.

You can get all types of addresses in BitcoinKit.swift level using new addressConverterChain from BitcoinCore. Or you have to implement method in BitcoinKit to get address from BitcoinCore:

You can’t pull an address at a specific derivation path using existing class architecture. You can use HSHDWalletKit pod from our repository directly and create PublicKey class to make publicKey