Giter Site home page Giter Site logo

go-electrum's Introduction

go-electrum GoDoc

A pure Go Electrum bitcoin library. This makes it easy to write bitcoin based services using Go without having to run a full bitcoin node.

go-electrum

This is very much WIP and has a number of unimplemented methods. This will eventually be rewritten into a more Go-esque library and handle wallet generation.

Packages provided

  • electrum - Library for using JSON-RPC to talk directly to Electrum servers.
  • wallet - A bitcoin wallet built on btcwallet with Electrum as the backend.
  • irc - A helper module for finding electrum servers using the #electrum IRC channel on Freenode.

Usage

See example/ for more.

electrum GoDoc

$ go get -u github.com/d4l3k/go-electrum/electrum
package main

import (
  "log"

  "github.com/d4l3k/go-electrum/electrum"
)

func main() {
	node := electrum.NewNode()
	if err := node.ConnectTCP("electrum.dragonzone.net:50001"); err != nil {
		log.Fatal(err)
	}
	balance, err := node.BlockchainAddressGetBalance("1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L")
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Address balance: %+v", balance)
}

wallet GoDoc

$ go get -u github.com/d4l3k/go-electrum/wallet
package main

import (
  "log"

  "github.com/btcsuite/btcutil"
  "github.com/d4l3k/go-electrum/wallet"
)

func main() {
  seed, err := hdkeychain.GenerateSeed(hdkeychain.RecommendedSeedLen)
  if err != nil {
    log.Fatal(err)
  }
  w, err := wallet.Create("test.wallet", "pass", seed)
  if err != nil {
    log.Fatal(err)
  }
  addrs, err := w.GenAddresses(1)
  if err != nil {
    log.Fatal(err)
  }
  log.Printf("Address: %s", addrs[0])
  err = w.SendBitcoin(map[string]btcutil.Amount{
    "18mS21JLSWJcTwKV8ZEv5SvroKAqkbYfPy": btcutil.NewAmount(1.0),
  }, 6)
  if err != nil {
    log.Fatal(err)
  }
}

irc GoDoc

$ go get -u github.com/d4l3k/go-electrum/irc
package main

import (
	"log"

	"github.com/d4l3k/go-electrum/irc"
)

func main() {
	log.Println(irc.FindElectrumServers())
}

License

go-electrum is licensed under the MIT license.

Made by Tristan Rice.

go-electrum's People

Contributors

d4l3k avatar elbandi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-electrum's Issues

Incompatibility with btcsuite

Hi,

It seems that go-electrum/wallet does not build anymore with up to date btcsuite package:

go get
# github.com/d4l3k/go-electrum/wallet
../github.com/d4l3k/go-electrum/wallet/wallet.go:43:17: cannot use maddr.Address() (type "github.com/btcsuite/btcwallet/vendor/github.com/btcsuite/btcutil".Address) as type "github.com/btcsuite/btcutil".Address in append:
    "github.com/btcsuite/btcwallet/vendor/github.com/btcsuite/btcutil".Address does not implement "github.com/btcsuite/btcutil".Address (wrong type for IsForNet method)
        have IsForNet(*"github.com/btcsuite/btcwallet/vendor/github.com/btcsuite/btcd/chaincfg".Params) bool
        want IsForNet(*"github.com/btcsuite/btcd/chaincfg".Params) bool
../github.com/d4l3k/go-electrum/wallet/wallet.go:80:43: cannot use amounts (type map[string]"github.com/btcsuite/btcutil".Amount) as type []*"github.com/btcsuite/btcwallet/vendor/github.com/btcsuite/btcd/wire".TxOut in argument to w.wallet.CreateSimpleTx
../github.com/d4l3k/go-electrum/wallet/wallet.go:88:51: createdTx.MsgTx undefined (type *txauthor.AuthoredTx has no field or method MsgTx)
../github.com/d4l3k/go-electrum/wallet/wallet.go:124:12: cannot use addr.Address() (type "github.com/btcsuite/btcwallet/vendor/github.com/btcsuite/btcutil".Address) as type "github.com/btcsuite/btcutil".Address in assignment:
    "github.com/btcsuite/btcwallet/vendor/github.com/btcsuite/btcutil".Address does not implement "github.com/btcsuite/btcutil".Address (wrong type for IsForNet method)
        have IsForNet(*"github.com/btcsuite/btcwallet/vendor/github.com/btcsuite/btcd/chaincfg".Params) bool
        want IsForNet(*"github.com/btcsuite/btcd/chaincfg".Params) bool
../github.com/d4l3k/go-electrum/wallet/wallet.go:140:15: cannot assign 1 values to 2 variables
../github.com/d4l3k/go-electrum/wallet/wallet.go:179:32: too many arguments in call to wallet.Open
    have (nil, *"github.com/btcsuite/btcwallet/vendor/github.com/btcsuite/btcd/chaincfg".Params, walletdb.DB, walletdb.Namespace, walletdb.Namespace, *waddrmgr.OpenCallbacks)
    want (walletdb.DB, []byte, *waddrmgr.OpenCallbacks, *"github.com/btcsuite/btcwallet/vendor/github.com/btcsuite/btcd/chaincfg".Params)`llet/vendor/github.com/btcsuite/btcd/chaincfg".Params)`

Get Addresses from Master Public Key

Hey!

Great library! As I understand it, one would be able to get all the addresses from the Master Public Key. I took a quick look and from the looks of it, it doesn't seem possible to just do that by this library. Is this something you could add support for?

The idea is that I would just need the Master Public Key, and then be able to get all the addresses from that using this library. No need with anything private that is.

Thanks!

Wallet not working, log included

# github.com/d4l3k/go-electrum/wallet
../../github.com/d4l3k/go-electrum/wallet/wallet.go:80: cannot use amounts (type map[string]btcutil.Amount) as type []*wire.TxOut in argument to w.wallet.CreateSimpleTx
../../github.com/d4l3k/go-electrum/wallet/wallet.go:88: createdTx.MsgTx undefined (type *txauthor.AuthoredTx has no field or method MsgTx)
../../github.com/d4l3k/go-electrum/wallet/wallet.go:140: assignment count mismatch: 2 = 1
../../github.com/d4l3k/go-electrum/wallet/wallet.go:179: too many arguments in call to wallet.Open
	have (nil, *chaincfg.Params, walletdb.DB, walletdb.Namespace, walletdb.Namespace, *waddrmgr.OpenCallbacks)
	want (walletdb.DB, []byte, *waddrmgr.OpenCallbacks, *chaincfg.Params)

Is your library ready to use for production?

I'm planning to build an application with following features in it.

  1. Will have an electrum wallet setup
  2. User can create multiple wallets
  3. User can create multiple addresses
  4. User can generate Seed of their wallets
  5. User can send BTC to other
  6. User can view transaction history

I want to confirm if I can use this library for these features or not. As it states that the project is still under progress, I would like to know which features have been completed successfully.

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.