Coder Social home page Coder Social logo

Comments (20)

mor2vin avatar mor2vin commented on August 30, 2024

Have you solved this problem?

from bitcoinkit.

SurpriseMF3000 avatar SurpriseMF3000 commented on August 30, 2024

Do you have any issues regarding to this?

from bitcoinkit.

mor2vin avatar mor2vin commented on August 30, 2024

No, I'm facing a similar problem. I thought maybe you have already found a solution?

from bitcoinkit.

mor2vin avatar mor2vin commented on August 30, 2024

Can you help me?

from bitcoinkit.

SurpriseMF3000 avatar SurpriseMF3000 commented on August 30, 2024

I will try to help you later;)

from bitcoinkit.

mor2vin avatar mor2vin commented on August 30, 2024

You mean not today? Let me know when you're ready to help.

from bitcoinkit.

SurpriseMF3000 avatar SurpriseMF3000 commented on August 30, 2024

Today

from bitcoinkit.

mor2vin avatar mor2vin commented on August 30, 2024

Ok

from bitcoinkit.

SurpriseMF3000 avatar SurpriseMF3000 commented on August 30, 2024
  1. Try to build everything like in the Readme.md
  2. Use Native Modules like JS and then call the JS function which contains your BTC Function from Swift

Notice: This library is over 4-5 years old without any updates so its kind of outdated

from bitcoinkit.

mor2vin avatar mor2vin commented on August 30, 2024

I'm a newbie. I didn't understand anything)

from bitcoinkit.

mor2vin avatar mor2vin commented on August 30, 2024

can you tell me more?

from bitcoinkit.

SurpriseMF3000 avatar SurpriseMF3000 commented on August 30, 2024

Opportunity 1. You try to build everything like in the documentation of this library. (Readme.md in Root of this project)

Opportunity 2. You use Native modules to call a Bitcoin JS function in Swift.
Explantation: you found a working Bitcoin function in a different Programming language like JavaScript.
You still want to use Swift as your primary programming language.
With Native Modules can you call a JS (can be any language if supported) Function in Swift.

from bitcoinkit.

mor2vin avatar mor2vin commented on August 30, 2024

I don't know). I want everything to work). I need a module that accepts seed and returns the current balance.

from bitcoinkit.

SurpriseMF3000 avatar SurpriseMF3000 commented on August 30, 2024

Would a Public Key instead of Seed Phrase also be ok?

from bitcoinkit.

mor2vin avatar mor2vin commented on August 30, 2024

No, only by seed.

from bitcoinkit.

SurpriseMF3000 avatar SurpriseMF3000 commented on August 30, 2024

Hello again,
use https://github.com/horizontalsystems/bitcoin-kit-ios library instead of this one because it is way more recent to get the Public Key from Seed Phrases.
To get the Balance, we use Alamofire (API module for Swift) and the api.blockcypher.com API.

You need to install: bitcoin-kit-ios and Alamofire in your Podfile

      pod 'BitcoinCore.swift'
      pod 'BitcoinKit.swift'
      pod 'Alamofire', '~> 5.6' 
  1. turn Seed Phrases to Public Key:
  func checkbalance(){
       
       print("CheckBalance start");
       
       var bitcoinKit: BitcoinKit
   
       let words = [Seed Phrases example:"special", "verb"] //implement here your seed phrases
       
       let seed = Mnemonic.seed(mnemonic: words)
   
       bitcoinKit = try! BitcoinKit(withWords: words, bip: .bip44, walletId: "bitcoin-wallet-id", syncMode: .api, networkType: .testNet, logger: .none) //if you want to use mainnet change to networkType: .mainNet
       
       
       bitcoinKit.start()
       
       let PublicKey = bitcoinKit.receiveAddress()

       print(PublicKey)

       print(bitcoinKit.balance) //would normally print the Balance but doesn't works at the moment

       print("BTC session completed!")
       
       
       bitcoinKit.stop()
   
   }
  1. Because bitcoinKit.balance doesn't works at the moment do we need to use a BTC API to get the Balance

API request via Alamofire Swift and api.blockcypher.com API

Where the address in the Link is, do you need to paste the address from which you want to know the balance.
You can do this by pasting a variable in there with the Wallet address.

AF.request("https://api.blockcypher.com/v1/btc/test3/addrs/address/balance").responseJSON { response in
            print(response)
            
            var WalletResponse = response
            
            print(WalletResponse)
            
        }

from bitcoinkit.

mor2vin avatar mor2vin commented on August 30, 2024

I did everything as you said, but I get a lot of errors. Could you assemble this module into a single file so that everything works.

from bitcoinkit.

SurpriseMF3000 avatar SurpriseMF3000 commented on August 30, 2024

Import and setup everything like I told you before.
Change the @IBOutlet weak var TextLabel: UILabel! (This is a TextLabel) and @IBAction func SendButton(_ sender: Any) (This is a Button) to your own and enter your mnemonics in the Script.

The ViewController.swift

//
//  ViewController.swift
//  Swift Bitcoin
//
//  Created by SurpriseMF3000 on 07.09.22.
//

import UIKit
import BitcoinKit
import BitcoinCore
import HdWalletKit
import HsToolKit
import RxSwift

import Alamofire

class ViewController: UIViewController {



    @IBOutlet weak var TextLabel: UILabel!
    


    @IBAction func SendButton(_ sender: Any) {
        
        checkbalance()
        
    }
   
    
    func checkbalance(){
        
        
        print("CheckBalance start");
  
        
        var bitcoinKit: BitcoinKit
    
        let words = [Enter here your mnemonics] //!!!!!!!!!!!!!!!!!!!!!
        
        let seed = Mnemonic.seed(mnemonic: words)
    
        bitcoinKit = try! BitcoinKit(withWords: words, bip: .bip44, walletId: "bitcoin-wallet-id", syncMode: .api, networkType: .testNet, logger: .none)
        
        
        bitcoinKit.start()
        
        
        print(bitcoinKit.receiveAddress())
        
        var publicKey = bitcoinKit.receiveAddress()
        
        print("PublicKey: " + publicKey)
        
        
        AF.request("https://api.blockcypher.com/v1/btc/test3/addrs/\(publicKey)/balance").responseJSON { response in
            print(response)
            
            var WalletResponse = response
            
            print("WalletResponse: " ,WalletResponse)
            

            
            let WalletBalance = (WalletResponse.result)
            
            
            print("Balance: ", WalletBalance)
            
        }
        
        
        
        print("BTC session completed!")
        
        
        bitcoinKit.stop()
    
    }
    
    
    
    
    
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }


}

from bitcoinkit.

mor2vin avatar mor2vin commented on August 30, 2024

Thank you, as soon as I have the opportunity to test your code

from bitcoinkit.

zhang2676105 avatar zhang2676105 commented on August 30, 2024

端点是怎么申请的,谢谢了

from bitcoinkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.