Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

code.dumpstack.io/lib/cryptocurrency

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code.dumpstack.io/lib/cryptocurrency

  • v1.5.3
  • Go
  • Socket score

Version published
Created
Source

GitHub Actions GoDoc Go Report Card Donate Donate

Cryptocurrency API

Stateless cryptocurrency API.

Requirements:

  • Bitcoin: electrum wallet in $PATH
  • Ethereum: export INFURA_API_KEY=... from infura.io (it's free). It'll work even without, but there are some limits on queries.

Start:

go get -u code.dumpstack.io/lib/cryptocurrency
go test -v code.dumpstack.io/lib/cryptocurrency/...

Usage:

package main

import (
	"log"

	"code.dumpstack.io/lib/cryptocurrency"
)

func main() {
	c := cryptocurrency.Bitcoin
	dest := "mk84dHbQoUHWaWGuYspx6GXWgcjB9CuQqw"
	// c := cryptocurrency.Ethereum
	// dest := "0xD98660C76443A8A043a19499048EeC4FB06f2581"
	// c := cryptocurrency.Cardano
	// dest := "Ae2tdPwUPEZ68cfEjZjKKRabiqbazMtP69uGaM2pMZRg87fvn4FGvR95BEV"

	err := c.Testnet(true)
	if err != nil {
		log.Fatal(err)
	}

	seed, address, err := c.GenWallet()
	if err != nil {
		log.Fatal(err)
	}
	log.Println(seed, address)

	balance, err := c.Balance(seed)
	log.Println(balance)
	if err != nil {
		log.Fatal(err)
	}

	valid, err := c.Validate(dest)
	if err != nil {
		log.Fatal(err)
	}
	if valid {
		log.Println("address", dest, "is valid")
	} else {
		log.Fatal("address", dest, "is invalid")
	}

	amount := float64(0.1)
	tx, err := c.Send(seed, dest, amount)
	// tx, err := c.SendUnits(seed, dest, wei) // precise version
	if err != nil {
		log.Println("here it'll exit because there's no money inside new wallet")
		log.Fatal(err)
	}
	log.Println(tx)
}

FAQs

Package last updated on 16 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc