Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ linters-settings:
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
require-specific: true
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments
- name: package-comments
severity: warning
disabled: true
rowserrcheck:
packages:
- github.com/jmoiron/sqlx
Expand Down Expand Up @@ -353,6 +359,10 @@ linters:
- goerr113
- testpackage
- nlreturn
- deadcode
- scopelint
- varcheck
- structcheck
- gci
disable-all: false
presets:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ run-linter:


install-linter:
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.35.2
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.49.0

go-doc-mac:
@open http://localhost:6060 && \
Expand Down
15 changes: 13 additions & 2 deletions merchant.go → beneficiary.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
/*
Package dpp defines some kind of DPP structure.

These structures are defined in the TSC spec:
https://tsc.bitcoinassociation.net/standards/direct_payment_protocol

This comment is here to qualify as the required make-work for the jobsworth who implemented the
revive "package-comment" linter.
*/
package dpp

// Merchant to be displayed to the user.
type Merchant struct {
// Beneficiary to be displayed to the user.
type Beneficiary struct {
// AvatarURL displays a canonical url to a merchants avatar.
AvatarURL string `json:"avatar" example:"http://url.com"`
// Name is a human readable string identifying the merchant.
Expand All @@ -12,4 +21,6 @@ type Merchant struct {
Address string `json:"address" example:"1 the street, the town, B1 1AA"`
// ExtendedData can be supplied if the merchant wishes to send some arbitrary data back to the wallet.
ExtendedData map[string]interface{} `json:"extendedData,omitempty"`
// PaymentReference ID of invoice.
PaymentReference string `json:"paymentReference" example:"Order-325214"`
}
35 changes: 0 additions & 35 deletions destinations.go

This file was deleted.

2 changes: 1 addition & 1 deletion mocks/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package mocks

//go:generate moq -pkg mocks -out payment_writer.go ../ PaymentWriter
//go:generate moq -pkg mocks -out payment_service.go ../ PaymentService
//go:generate moq -pkg mocks -out payment_request_service.go ../ PaymentRequestService
//go:generate moq -pkg mocks -out payment_request_service.go ../ PaymentTermsService
76 changes: 39 additions & 37 deletions mocks/payment_request_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions mocks/payment_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions mocks/payment_writer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions modes/hybridmode/hybrid_payment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Package hybridmode defines the subset of the DPP payment terms structure related to the hybrid mode.

These structures are defined in the TSC spec:
https://tsc.bitcoinassociation.net/standards/direct_payment_protocol

This comment is here to qualify as the required make-work for the jobsworth who implemented the
revive "package-comment" linter.
*/
package hybridmode

import "github.com/libsv/go-bc/spv"

// Payment includes data required for hybridmode payment mode.
type Payment struct {
// OptionID ID of chosen payment options
OptionID string `json:"optionId"`
// Transactions A list of valid, signed Bitcoin transactions that fully pays the PaymentTerms.
// The transaction is hex-encoded and must NOT be prefixed with “0x”.
// The order of transactions should match the order from PaymentTerms for this mode.
Transactions []string `json:"transactions"`
// Ancestors a map of txid to ancestry transaction info for the transactions in <optionID> above
// each ancestor contains the TX together with the MerkleProof needed when SPVRequired is true.
// See: https://tsc.bitcoinassociation.net/standards/transaction-ancestors/
Ancestors map[string]spv.TSCAncestryJSON `json:"ancestors"`
}
17 changes: 17 additions & 0 deletions modes/hybridmode/hybrid_payment_ack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package hybridmode


// PeerChannelData holds peer channel information for subscribing to and reading from a peer channel.
type PeerChannelData struct {
Host string `json:"host"`
Path string `json:"path"`
ChannelID string `json:"channel_id"`
Token string `json:"token"`
}


// PaymentACK includes data required for hybridmode payment mode.
type PaymentACK struct {
TransactionIds []string `json:"transactionIds"`
PeerChannel *PeerChannelData `json:"peerChannel"`
}
38 changes: 38 additions & 0 deletions modes/hybridmode/hybrid_payment_terms.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package hybridmode

import (
"github.com/libsv/go-dpp/nativetypes"
)

// Policies An object containing some policy information like fees or whether Ancestors are
// required in the `Payment`.
type Policies struct {
// FeeRate defines the amount of fees a users wallet should add to the payment
// when submitting their final payments.
FeeRate map[string]map[string]int `json:"fees,omitempty"`
SPVRequired bool `json:"SPVRequired,omitempty"`
LockTime uint32 `json:"lockTime,omitempty"`
}

// Inputs provides options of different arrays of input script types.
// Currently, only "native" type input are supported.
type Inputs struct {
NativeOutputs []nativetypes.NativeInput `json:"native"`
}

// Outputs provides options of different arrays of output script types.
// Currently, only "native" type outputs are supported.
type Outputs struct {
NativeOutputs []nativetypes.NativeOutput `json:"native"`
}

// TransactionTerms a single definition of requested transaction format for the standard payment mode:
// "ef63d9775da5" in the DPP TSC spec.
type TransactionTerms struct {
Outputs Outputs `json:"outputs"`
Inputs Inputs `json:"inputs,omitempty"`
Policies *Policies `json:"policies"`
}

// PaymentTerms message used in DPP TSC spec. for the `PaymentTerms` message.
type PaymentTerms map[string]map[string][]TransactionTerms
Loading