Categorygithub.com/libsv/go-dpp
modulepackage
0.1.12-330cf5
Repository: https://github.com/libsv/go-dpp.git
Documentation: pkg.go.dev

# README

DPP - Direct Payment Protocol

Release Build Status Report Go Sponsor Donate

DPP is a basic reference implementation of a Payment Protocol Server implementing the proposed BIP-270 payment flow.

This is written in go and integrates with a wallet running the Payment Protocol PayD Interface.

Exploring Endpoints

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

Configuring DPP

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

KeyDescriptionDefault
SERVER_PORTPort which this server should use:8445
SERVER_HOSTHost name under which this server is founddpp
SERVER_SWAGGER_ENABLEDIf set to true we will expose an endpoint hosting the Swagger docstrue
SERVER_SWAGGER_HOSTSets the base url for swagger ui callslocalhost:8445

Environment / Deployment Info

KeyDescriptionDefault
ENV_ENVIRONMENTWhat enviornment we are running in, for example 'production'dev
ENV_REGIONRegion we are running in, for example 'eu-west-1'local
ENV_COMMITCommit hash for the current buildtest
ENV_VERSIONSemver tag for the current build, for example v1.0.0v0.0.0
ENV_BUILDDATEDate the code was buildCurrent UTC time
ENV_BITCOIN_NETWORKWhat bitcoin network we are connecting to (mainnet, testnet, stn, regtest)regtest

Logging

KeyDescriptionDefault
LOG_LEVELLevel of logging we want within the server (debug, error, warn, info)info

PayD Wallet

KeyDescriptionDefault
PAYD_HOSTHost for the wallet we are connecting topayd
PAYD_PORTPort the PayD wallet is listening on:8443
PAYD_SECUREIf true the DPP server will validate the wallet TLS certsfalse
PAYD_NOOPIf true we will use a dummy data store in place of paydtrue

Working with DPP

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 dpp in docker.

make run-compose - runs DPP in compose, a reference PayD wallet will be added to compose soon NOTE the above command will need ran first.

Rebuild on code change

You can also add an optional docker-compose.dev.yml file (this is not committed) where you can safely overwrite values or add other services without impacting the main compose file.

If you add this file, you can run it with make run-compose-dev.

The file I use has a watcher which means it auto rebuilds the image on code change and ensures compose is always up to date, this full file is shown below:

version: "3.7"

services:
  dpp:
    image: theflyingcodr/go-watcher:1.15.8
    environment:
      GO111MODULE: "on"
      GOFLAGS: "-mod=vendor"
      DB_DSN: "file:data/wallet.db?cache=shared&_foreign_keys=true;"
      DB_SCHEMA_PATH: "data/sqlite/migrations"
    command: watcher -run github.com/libsv/go-dpp/cmd/rest-server/ -watch github.com/libsv/go-dpp
    working_dir: /go/src/github.com/libsv/go-dpp
    volumes:
      - ~/git/libsv/go-dpp:/go/src/github.com/libsv/go-dpp

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.

# Packages

No description provided by the author
No description provided by the author
Package nativetypes defines some kind of DPP structure.

# Structs

Beneficiary to be displayed to the user.
Originator Data about payer.
Payment is a Payment message used in BIP270.
PaymentACK message used in the TSC DPP spec.
PaymentCreateArgs identifies the paymentID used for the payment.
PaymentTerms message as defined in the DPP T$C spec.
PaymentTermsArgs are request arguments that can be passed to the service.
PaymentTermsModes message used in DPP TSC spec.
ProofCallback is used by a payee to request a merkle proof is sent to them as proof of acceptance of the tx they have provided in the ancestry.
ProofCreateArgs are used to create a proof.
ProofWrapper represents a mapi callback payload for a merkleproof.

# Interfaces

PaymentService enforces business rules when creating payments.
PaymentTermsReader will return a new payment request.
PaymentTermsService can be implemented to enforce business rules and process in order to fulfil PaymentTerms.
PaymentWriter will write a payment to a data store.
ProofsService enforces business rules and validation when handling merkle proofs.
ProofsWriter is used to persist a proof to a data store.