Code Monkey home page Code Monkey logo

payd's Introduction

payd

Release Build Status Report codecov Go Sponsor Donate

Payd is a basic dummy wallet (do not use this) for demonstrating the BIP 270 / Payment Protocol flow.

It has a random master key, created at startup and a single user support for now and no authentication. Seriously, don't use this wallet at the moment expect for demonstration purposes.

This wallet has an Invoice interface with CRUD operations for creating payment invoices and also implements the Wallet Payment Protocol Interface, used to integration with payment protocol servers.

This is written in go and integrates with servers running the Payment Protocol Interface.

Exploring Endpoints

To explore the endpoints and functionality, run the server using go run cmd/rest-server/main.go and navigate to Swagger or go to the GitHub Pages hosting the spec here where the endpoints and their models are described in detail.

Configuring PayD

The server has a series of environment variables that allow you to configure the behaviours and integrations of the server. Values can also be passed at build time to provide information such as build information, region, version etc.

Server

Key Description Default
SERVER_PORT Port which this server should use :8443
SERVER_HOST Host name under which this server is found payd:8443
SERVER_SWAGGER_ENABLED If set to true we will expose an endpoint hosting the Swagger docs true
SERVER_SWAGGER_HOST The host that swagger will point its api requests to localhost:8443

Environment / Deployment Info

Key Description Default
ENV_ENVIRONMENT What enviornment we are running in, for example 'production' dev
ENV_REGION Region we are running in, for example 'eu-west-1' local
ENV_COMMIT Commit hash for the current build test
ENV_VERSION Semver tag for the current build, for example v1.0.0 v0.0.0
ENV_BUILDDATE Date the code was build Current UTC time

Logging

Key Description Default
LOG_LEVEL Level of logging we want within the server (debug, error, warn, info) info

DB

Key Description Default
DB_TYPE Type of db you're connecting to (sqlite, postgres,mysql) sqlite only supported currently sqlite
DB_DSN Connection string for the db file:data/wallet.db?_foreign_keys=true&pooled=true
DB_SCHEMA_PATH Location of the data base migration scripts data/sqlite/migrations
DB_MIGRATE If true we will check the db version and apply missing migrations true

Headers Client

If validating using SPV you will need to run a Headers Client, this will sync headers as they are mined and provide block and merkle proof information.

Key Description Default
HEADERSCLIENT_ADDRESS Uri for the headers client you are using http://headersv:8080
HEADERSCLIENT_TIMEOUT Timeout in seconds for headers client queries 30

Wallet

Key Description Default
WALLET_NETWORK Bitcoin network we're connected to (regtest, stn, testnet,regtest) regtest
WALLET_SPVREQUIRED If true we will require full SPV envelopes to be sent as part of payments true
WALLET_PAYMENTEXPIRY Duration in hours that invoices will be valid for 24

Working with PayD

There are a set of makefile commands listed under the Makefile which give some useful shortcuts when working with the repo.

Some of the more common commands are listed below:

make pre-commit - ensures dependencies are up to date and runs linter and unit tests.

make build-image - builds a local docker image, useful when testing PayD in docker.

make run-compose - runs PayD in compose using the latest available image.

make run-compose-faucet - runs a local payD instance that connects to the infra.bitcoinsv.io dpp proxy. Used to receive funds from faucet.bitcoinsv.io.

make run-compose-local - will run payd and use a local image built using the above make build-image command.

Using the Faucet

There is a testnet 'faucet' setup at faucet.bitcoinsv.io that can be used to get funds from.

Because of the new invoice based payments system, this can send funds to any wallet that also supports invoice based payments.

To get funds, simply run make run-compose-faucet. This will run a local payd instance and connect it to the faucet infrastructure.

Next, send the following call to your local payd instance:

curl --location --request POST 'http://localhost:8443/api/v1/invoices' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
    "satoshis":1000
}'

This will create an invoice and also connect your payd to the faucet dpp server which orchestrates the payments.

You will get a response back like this:

{
    "createdAt": "2022-08-03T12:41:57.967516Z",
    "deletedAt": null,
    "description": null,
    "expiresAt": "2022-08-04T12:41:57.967516Z",
    "id": "DBVb00g",
    "paymentReceivedAt": null,
    "reference": null,
    "refundTo": null,
    "refundedAt": null,
    "satoshis": 200,
    "state": "pending",
    "updatedAt": "2022-08-03T12:41:57Z"
}

Copy the "id" and then go to faucet.bitcoinsv.io, in the box for the URL enter https://infra.bitcoinsv.io/dpp/api/v1/payment/DBVb00g where the id at the end, is the id returned from the above call.

Hit the Pay To URL button and the funds requested will be sent to your local wallet.

For further information view the Liteclient Documentation.

Releases

You can view the latest releases on our Github Releases page.

We also publish docker images which can be found on Docker Hub.

CI / CD

We use github actions to test and build the code.

If a new release is required, after your PR is approved and code added to master, simply add a new semver tag and a GitHub action will build and publish your code as well as create a GitHub release.

payd's People

Contributors

danconnolly avatar dependabot[bot] avatar jadwahab avatar mergify[bot] avatar roppa avatar theflyingcodr avatar tigh-latte avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

payd's Issues

Handcash - paymentACK errors

When using Handcash to submit a payment and the BIP-270 server returns a paymentACK with an error > 1, I would have expected to have seen an error in the app rather than the payment complete. Is this an issue with how handcash are handling the paymentACK message or something missing from the Spec.

In the protocol spec it defines the PaymentACK message as shown: https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki#paymentack.

error A number indicating why the transaction was not accepted. 0 or undefined indicates no error. A 1 or any other positive integer indicates an error. The errors are left undefined for now; it is recommended only to use "1" and to fill the memo with a textual explanation about why the transaction was not accepted until further numbers are defined and standardized.

REFACTOR

Rename Headersv with HeadersClient

Handcash - general errors

When we were testing Payd with handcash we submitted an incorrect URL for the payment endpoint, the app just displayed a message saying "note too long" - I wonder could there be a better method of logging this - I understand they are trying to keep this as user friendly as possible but keeping it simple but perhaps something like "payment failed / payment unavailable" or something could be better here?

Docker image for goreleaser

Right now goreleaser has it's own built binary so we just copy it over into the docker image but then we have some duplication so we have 2 Dockerfiles. (one for local builds and one for releaser builds)

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.