A work-in-progress Bitcoin wallet based on Output Descriptors

go-wallet

Build Status Go Reference

A work-in-progress Bitcoin wallet

Descriptors

go-wallet is designed around Bitcoin Descriptors. It implements a Output Script Descriptors language parser which returns valid outputs scripts. The script package also implements a Output Script DSL to build scripts with a fluent API.

Supported scripts

Script Type Operator
P2SH sh(SCRIPT)
P2WSH wsh(SCRIPT)
P2PK pk(KEY)
P2PKH pkh(KEY)
P2WPKH wpkh(KEY)
combo(KEY)
Multi multi(k,<keys>
Sortedmulti sortedmulti(k,<keys>
P2TR tr() or tr(KEY, TREE)
addr(ADDR)
hex(HEX)

Example

The following example shows how to parse a Script and print an address.

package main

import (
	"fmt"
	"log"

	"github.com/qustavo/go-wallet"
	"github.com/qustavo/go-wallet/script"
)

func main() {
	w, err := wallet.NewWallet(`
		wsh(sortedmulti(2,
			0375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c,
			03a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff,
			03c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f880
	))`, script.Mainnet)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("> addr: %s\n", w.Address())
}

The same can be expresses using the script API.

package main

import (
	"fmt"
	"log"

	. "github.com/qustavo/go-wallet/script"
)

func main() {
	script := Wsh(Sortedmulti(2,
		"0375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c",
		"03a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff",
		"03c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f880",
	))
	eval, err := script.Eval()
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("> addr: %s\n", eval.Address(Mainnet))
}
Owner
Gustavo Chaín
Technical Dealer
Gustavo Chaín
Similar Resources

A simple ticket-wallet API. It is fully dockerized

Ticket Wallet This is a simple ticket-wallet API. It is fully dockerized. Table of contents 1 Response Data format 2 API  2.1 Get layout  2.2 Start se

Jan 23, 2022

Blockcain - Trust Wallet token repository - A comprehensive, up-to-date collection of information about several thousands (!) of crypto tokens

Blockcain - Trust Wallet token repository - A comprehensive, up-to-date collection of information about several thousands (!) of crypto tokens

Trust Wallet Assets Info Overview Trust Wallet token repository is a comprehensi

Feb 14, 2022

A full node Bitcoin (BSV) implementation written in Go

bsvd bsvd is a full node Bitcoin (BSV) implementation written in Go (golang). This project is a port of the bchd codebase to Bitcoin (BSV). It provide

Dec 25, 2022

A db for bitcoin-sv & BTC

Welcome to go-svdb Project =========== Boquan Team The Boquan is a team dedicated to promoting and developing true bitcoin. The team has successfully

Sep 3, 2021

Moeing chain is an EVM&Web3 compatible sidechain for Bitcoin Cash

Full node client of smartBCH This repository contains the code of the full node client of smartBCH, an EVM&Web3 compatible sidechain for Bitcoin Cash.

Nov 29, 2022

Store data on Bitcoin for 350 sats/KB up to 185 KB by using P2SH-P2WSH witness scripts

Bitcandle Store data on Bitcoin for 350 sats/KB up to 185 kB by using P2SH-P2WSH witness scripts. 225ed8bc432d37cf434f80717286fd5671f676f12b573294db72

Aug 12, 2022

A curated Golang toolkit for creating Bitcoin SV powered apps

A curated Golang toolkit for creating Bitcoin SV powered apps

bsv A curated Golang toolkit for creating Bitcoin SV powered apps Table of Contents Installation Maintainers License Installation bsv requires a suppo

May 10, 2022

The go-to Bitcoin Node (BN) Go library.

go-bitcoin Go wrapper for bitcoin RPC RPC services Start by creating a connection to a bitcoin node b, err := New("rcp host", rpc port, "rpc usernam

Feb 13, 2022

Bitcoin CPU miner written in Go.

CPU Miner Bitcoin CPU miner written in Go. Introduction This is a CPU miner written in Go. It is a proof of concept and is not intended for production

Dec 29, 2022
Ethereum-vanity-wallet - A fork of https://github.com/meehow/ethereum-vanity-wallet but the key can be exported to a JSON keystore file

ethereum-vanity-wallet See https://github.com/meehow/ethereum-vanity-wallet This version: doesn't display the private key let's you interactively expo

Jan 2, 2022
Scp-wallet-api - Backend for SCP Wallet app

SCP Wallet API Backend for SCP Wallet app. It exposes a simplified REST API whic

Jan 31, 2022
Personal-Solana-Wallet - Create your personal wallet on Solana blockchain

Personal Wallet on Solana using Go ♾️ Setting up environment Installation of Cob

Nov 9, 2022
Go implementation of a vanity attempt to generate Bitcoin private keys and subsequently checking whether the corresponding Bitcoin address has a non-zero balance.

vanity-BTC-miner Go implementation of a vanity attempt to generate Bitcoin private keys and subsequently checking whether the corresponding Bitcoin ad

Jun 3, 2022
SwissWallet is a deterministic cryptocurrency wallet generator heavily based on MindWallet and MemWallet

SwissWallet SwissWallet is a deterministic cryptocurrency wallet generator heavily based on MindWallet and MemWallet but using argon2 and scrypt by de

Jul 28, 2022
An easy to setup local crypto wallet based on Geth

CryptoWallet An easy to setup local crypto wallet based on Geth To run. go run CrytoWallet This will expose a set a api's. To Create new Wallet curl

Oct 15, 2021
A plugin that turn hashicorp vault into blockchain wallet.
A plugin that turn hashicorp vault into blockchain wallet.

dq-vault - Hashicorp vault BTC/ETH plugin This vault plugin stores a user's mnemonic inside vault in an encrypted manner. The plugin uses this stored

Dec 7, 2022
Simple and useful principle of wallet in blockchain
Simple and useful principle of wallet in blockchain

Blockchain wallet utiles Development export GOPROXY=https://goproxy.io,direct go run *.go Build go build -o ./bin/app *.go About wallet in blockchain

Aug 11, 2022
API wrapper over high-load TON wallet

highload-wallet-api API wrapper over high-load TON wallet smart contract. Can be

Nov 4, 2022
Minilotus - A simple wallet manager of lotus

A simple wallet manager of lotus. Refer to https://github.com/filecoin-project/l

Jan 5, 2022