Code Monkey home page Code Monkey logo

electrumrpc's Introduction

Electrum JSON RPC Client

Build Status Go Report Card GoDoc License MIT

Note: The library does not have implementations of all Electrum RPC resources[WIP]. PRs for new resources and endpoints are welcome, or you can simply implement some yourself as-you-go.

Preposition

1. Install Electrum and create a wallet

2. Set RPC port

By default, it's random port - set it to any port you want

./run_electrum setconfig rpcport 7777

3. Set user and password for RPC

./run_electrum setconfig rpcuser user
./run_electrum setconfig rpcpassword password

4. Run Electrum as daemon

./run_electrum daemon start

If you want to start in testnet mode

./run_electrum --testnet daemon start

5. Load daemon wallet

./run_electrum daemon load_wallet

If daemon is running in testnet, you need to specify to load testnet wallet

./run_electrum --testnet daemon load_wallet

Now you have a local Electrum JSON RPC server running - congrats ๐Ÿฅณ

If you need to stop it, use

./run_electrum daemon stop

or if running in testnet

./run_electrum --testnet daemon stop

Install

go get github.com/MarinX/electrumrpc

Use

import "github.com/MarinX/electrumrpc"

Example

You can find more in electrumrpc_test.go

// httpClient is optional
// if nil, the http.DefaultClient will be used
client := electrumrpc.New("<rpc-user>", "<rpc-password>", "<rpc-endpoint>", nil)

// Call RPC methods
ver, err := client.Version()
if err != nil {
	//handle error
	panic(err)
}
fmt.Println("Electrum version:", ver)

Not all endpoints are implemented right now. In those case, you can use Call method and point your model

var rpcResponse string
err := client.Call("version", nil, &rpcResponse)
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println("Electrum version:", rpcResponse)

Available RPC methods

RPC Method Available
version โœ…
getaddressbalance โœ…
getbalance โœ…
validateaddress โœ…
getservers โœ…
createnewaddress โœ…
getunusedaddress โœ…
ismine โœ…
gettransaction โœ…
getseed โœ…
listaddresses โœ…
addrequest โœ…
rmrequest โœ…
clearrequests โœ…
getrequest โœ…
getfeerate โœ…
signmessage โœ…
verifymessage โœ…

Contributing

PR's are welcome. Please read CONTRIBUTING.md for more info

License

MIT

electrumrpc's People

Contributors

bitbandi avatar marinx avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.