Documentation
¶
Index ¶
- type DPPInput
- type DPPNativeOutput
- type DPPOutputs
- type DPPPolicies
- type Merchant
- type Payment
- type PaymentACK
- type PaymentCreateArgs
- type PaymentModes
- type PaymentRequest
- type PaymentRequestArgs
- type PaymentRequestReader
- type PaymentRequestService
- type PaymentService
- type PaymentWriter
- type PeerChannelData
- type ProofCallback
- type ProofCreateArgs
- type ProofWrapper
- type ProofsService
- type ProofsWriter
- type TransactionTerms
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DPPInput ¶
type DPPInput struct {
ScriptSig string `json:"scriptSig" binding:"required"` // string. required.
TxId string `json:"txid" binding:"required"` // string. required.
Vout uint32 `json:"vout" binding:"required"` // integer. required.
Value uint64 `json:"value" binding:"required"` // integer. required.
NSequence int `json:"nSequence,omitempty"` // number. optional.
}
type DPPNativeOutput ¶
type DPPNativeOutput struct {
// Amount is the number of satoshis to be paid.
Amount uint64 `json:"amount" binding:"required" example:"100000"`
// Script is a locking script where payment should be sent, formatted as a hexadecimal string.
LockingScript *bscript.Script `json:"script" binding:"required" swaggertype:"primitive,string" example:"76a91455b61be43392125d127f1780fb038437cd67ef9c88ac"`
// Description, an optional description such as "tip" or "sales tax". Maximum length is 100 chars.
Description string `json:"description,omitempty" example:"paymentReference 123456"`
}
type DPPOutputs ¶
type DPPOutputs struct {
NativeOutputType DPPNativeOutput `json:"native"`
}
type DPPPolicies ¶
type Merchant ¶
type Merchant 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.
Name string `json:"name" example:"merchant 1"`
// Email can be sued to contact the merchant about this transaction.
Email string `json:"email" example:"merchant@m.com"`
// Address is the merchants store / head office address.
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"`
}
Merchant to be displayed to the user.
type Payment ¶
type Payment struct {
// MerchantData is copied from PaymentDetails.merchantData.
// Payment hosts may use invoice numbers or any other data they require to match Payments to PaymentRequests.
// Note that malicious clients may modify the merchantData, so should be authenticated
// in some way (for example, signed with a payment host-only key).
// Maximum length is 10000 characters.
MerchantData Merchant `json:"merchantData"`
// RefundTo is a paymail to send a refund to should a refund be necessary.
// Maximum length is 100 characters
RefundTo *string `json:"refundTo" swaggertype:"primitive,string" example:"me@paymail.com"`
// Memo is a plain-text note from the customer to the payment host.
Memo string `json:"memo" example:"for invoice 123456"`
// Ancestry which contains the details of previous transaction and Merkle proof of each input UTXO.
// Should be available if AncestryRequired is set to true in the paymentRequest.
// See https://tsc.bitcoinassociation.net/standards/spv-envelope/
Ancestry *string `json:"ancestry"`
// RawTX should be sent if AncestryRequired is set to false in the payment request.
RawTx *string `json:"rawTx"`
// ProofCallbacks are optional and can be supplied when the sender wants to receive
// a merkleproof for the transaction they are submitting as part of the SPV Envelope.
//
// This is especially useful if they are receiving change and means when they use it
// as an input, they can provide the merkle proof.
ProofCallbacks map[string]ProofCallback `json:"proofCallbacks"`
}
Payment is a Payment message used in BIP270. See https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki#payment
type PaymentACK ¶
type PaymentACK struct {
ID string `json:"id"`
TxID string `json:"tx_id"`
Memo string `json:"memo"`
PeerChannel *PeerChannelData `json:"peer_channel"`
// 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 standardised.
Error int `json:"error,omitempty"`
}
PaymentACK message used in BIP270. See https://github.com/moneybutton/bips/blob/master/bip-0270.mediawiki#paymentack
type PaymentCreateArgs ¶
type PaymentCreateArgs struct {
PaymentID string `param:"paymentID"`
}
PaymentCreateArgs identifies the paymentID used for the payment.
func (PaymentCreateArgs) Validate ¶
func (p PaymentCreateArgs) Validate() error
Validate will ensure that the PaymentCreateArgs are supplied and correct.
type PaymentModes ¶
type PaymentModes struct {
HybridPaymentMode map[string]map[string][]TransactionTerms `json:"ef63d9775da5"`
}
PaymentModes message used in DPP TSC spec. At present we will strictly only allow the "standard" mode of payment with native bitcoins (satoshis). Handling of tokens is left for a later date.
type PaymentRequest ¶
type PaymentRequest struct {
// Network Always set to "bitcoin" (but seems to be set to 'bitcoin-sv'
// outside bip270 spec, see https://handcash.github.io/handcash-merchant-integration/#/merchant-payments)
// {enum: bitcoin, bitcoin-sv, test}
// Required.
Network string `json:"network" binding:"required" example:"mainnet" enums:"mainnet,testnet,stn,regtest"`
// Version version of DPP TSC spec.
// Required.
Version string `json:"version" binding:"required" example:"1.0"`
// Outputs an array of outputs. DEPRECATED but included for backward compatibility.
// Optional.
Outputs []DPPNativeOutput `json:"outputs,omitempty"`
// CreationTimestamp Unix timestamp (seconds since 1-Jan-1970 UTC) when the PaymentRequest was created.
// Required.
CreationTimestamp time.Time `json:"creationTimestamp" binding:"required" swaggertype:"primitive,string" example:"2019-10-12T07:20:50.52Z"`
// ExpirationTimestamp Unix timestamp (UTC) after which the PaymentRequest should be considered invalid.
// Optional.
ExpirationTimestamp time.Time `json:"expirationTimestamp" binding:"required" swaggertype:"primitive,string" example:"2019-10-12T07:20:50.52Z"`
// PaymentURL secure HTTPS location where a Payment message (see below) will be sent to obtain a PaymentACK.
// Maximum length is 4000 characters
PaymentURL string `json:"paymentUrl" binding:"required" example:"http://localhost:3443/api/v1/payment/123456"`
// Memo note that should be displayed to the customer, explaining what this PaymentRequest is for.
// Maximum length is 50 characters.
// Optional.
Memo string `json:"memo,omitempty" example:"invoice number 123456"`
// Beneficiary Arbitrary data that may be used by the payment host to identify the PaymentRequest
// May be omitted if the payment host does not need to associate Payments with PaymentRequest
// or if they associate each PaymentRequest with a separate payment address.
// Maximum length is 10000 characters.
// Optional.
Beneficiary *Merchant `json:"beneficiary,omitempty"`
// Modes TSC payment modes specified by ID (and well defined) modes customer can choose to pay
// A key-value map. required field but not if legacy BIP270 outputs are provided
Modes *PaymentModes `json:"modes"`
}
PaymentRequest message as defined in the DPP T$C spec.
type PaymentRequestArgs ¶
type PaymentRequestArgs struct {
// PaymentID is an identifier for an invoice.
PaymentID string `param:"paymentID"`
}
PaymentRequestArgs are request arguments that can be passed to the service.
type PaymentRequestReader ¶
type PaymentRequestReader interface {
PaymentRequest(ctx context.Context, args PaymentRequestArgs) (*PaymentRequest, error)
}
PaymentRequestReader will return a new payment request.
type PaymentRequestService ¶
type PaymentRequestService interface {
PaymentRequestReader
}
PaymentRequestService can be implemented to enforce business rules and process in order to fulfil a PaymentRequest.
type PaymentService ¶
type PaymentService interface {
PaymentCreate(ctx context.Context, args PaymentCreateArgs, req Payment) (*PaymentACK, error)
}
PaymentService enforces business rules when creating payments.
type PaymentWriter ¶
type PaymentWriter interface {
PaymentCreate(ctx context.Context, args PaymentCreateArgs, req Payment) (*PaymentACK, error)
}
PaymentWriter will write a payment to a data store.
type PeerChannelData ¶
type PeerChannelData struct {
Host string `json:"host"`
Path string `json:"path"`
ChannelID string `json:"channel_id"`
Token string `json:"token"`
}
PeerChannelData holds peer channel information for subscribing to and reading from a peer channel.
type ProofCallback ¶
type ProofCallback struct {
Token string `json:"token"`
}
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.
type ProofCreateArgs ¶
type ProofCreateArgs struct {
// TxID will be used to validate the proof envelope.
TxID string `json:"txId" param:"txid"`
PaymentReference string `query:"i"`
}
ProofCreateArgs are used to create a proof.
type ProofWrapper ¶
type ProofWrapper struct {
CallbackPayload *bc.MerkleProof `json:"callbackPayload"`
BlockHash string `json:"blockHash"`
BlockHeight uint32 `json:"blockHeight"`
CallbackTxID string `json:"callbackTxID"`
CallbackReason string `json:"callbackReason"`
}
ProofWrapper represents a mapi callback payload for a merkleproof. mAPI returns proofs in a JSONEnvelope with a payload. This represents the Payload format which contains a parent object with tx meta and a nested object which is the TSC format merkleProof.
func (ProofWrapper) Validate ¶
func (p ProofWrapper) Validate(args ProofCreateArgs) error
Validate will ensure the ProofWrapper is valid.
type ProofsService ¶
type ProofsService interface {
// Create will store a JSONEnvelope that contains a merkleproof. The envelope should
// be validated to not be tampered with and the Envelope should be opened to check the payload
// is indeed a MerkleProof.
Create(ctx context.Context, args ProofCreateArgs, req envelope.JSONEnvelope) error
}
ProofsService enforces business rules and validation when handling merkle proofs.
type ProofsWriter ¶
type ProofsWriter interface {
// ProofCreate can be used to persist a merkle proof in TSC format.
ProofCreate(ctx context.Context, args ProofCreateArgs, req envelope.JSONEnvelope) error
}
ProofsWriter is used to persist a proof to a data store.
type TransactionTerms ¶
type TransactionTerms struct {
Outputs []DPPOutputs `json:"outputs"`
Inputs []DPPInput `json:"inputs,omitempty"`
Policies *DPPPolicies `json:"policies"`
}
TransactionTerms a single definition of requested transaction format for the standard payment mode: "ef63d9775da5" in the DPP TSC spec.