models

package module
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 3 Imported by: 20

README

SPV Wallet: Models

Release Build Status Report Mergify Status

Go standard-readme compliant Makefile Included


Table of Contents


About

SPV Wallet internal models & structs


Installation

go-template requires a supported release of Go.

go get -u github.com/bitcoin-sv/spv-wallet-models

Documentation

View the generated documentation

GoDoc


Repository Features

This repository was created using MrZ's go-template

Built-in Features
Package Dependencies
Library Deployment

Releases are automatically created when you create a new git tag!

If you want to manually make releases, please install GoReleaser:

goreleaser for easy binary or library deployment to GitHub and can be installed:

  • using make: make install-releaser
  • using brew: brew install goreleaser

The .goreleaser.yml file is used to configure goreleaser.


Automatic releases via GitHub Actions from creating a new tag:

make tag version=1.2.3

Manual Releases (optional)

Use make release-snap to create a snapshot version of the release, and finally make release to ship to production (manually).


Makefile Commands

View all makefile commands

make help

List of all current commands:

all                           Runs multiple commands
clean                         Remove previous builds and any cached data
clean-mods                    Remove all the Go mod cache
coverage                      Shows the test coverage
diff                          Show the git diff
generate                      Runs the go generate command in the base of the repo
godocs                        Sync the latest tag with GoDocs
help                          Show this help message
install                       Install the application
install-all-contributors      Installs all contributors locally
install-go                    Install the application (Using Native Go)
install-releaser              Install the GoReleaser application
lint                          Run the golangci-lint application (install if not found)
release                       Full production release (creates release in GitHub)
release                       Runs common.release then runs godocs
release-snap                  Test the full release (build binaries)
release-test                  Full production test release (everything except deploy)
replace-version               Replaces the version in HTML/JS (pre-deploy)
tag                           Generate a new tag and push (tag version=0.0.0)
tag-remove                    Remove a tag if found (tag-remove version=0.0.0)
tag-update                    Update an existing tag to current commit (tag-update version=0.0.0)
test                          Runs lint and ALL tests
test-ci                       Runs all tests via CI (exports coverage)
test-ci-no-race               Runs all tests via CI (no race) (exports coverage)
test-ci-short                 Runs unit tests via CI (exports coverage)
test-no-lint                  Runs just tests
test-short                    Runs vet, lint and tests (excludes integration tests)
test-unit                     Runs tests and outputs coverage
uninstall                     Uninstall the application (and remove files)
update-contributors           Regenerates the contributors html/list
update-linter                 Update the golangci-lint package (macOS only)
vet                           Run the Go vet application

Usage

Examples & Tests

All unit tests run via GitHub Actions and uses Go version 1.18.x. View the configuration file.


Run all tests (including integration tests)

make test

Run tests (excluding integration tests)

make test-short

Benchmarks

Run the Go benchmarks:

make bench

Code Standards

Read more about this Go project's code standards.


Contributing

All kinds of contributions are welcome!
To get started, take a look at code standards.
View the contributing guidelines and follow the code of conduct.


License

License

Documentation

Overview

Package models contains all models (contracts) between spv-wallet api and other spv-wallet solutions

Index

Examples

Constants

View Source
const (
	// AuthHeader is the header to use for authentication (raw xPub)
	AuthHeader = "x-auth-xpub"

	// AuthAccessKey is the header to use for access key authentication (access public key)
	AuthAccessKey = "x-auth-key"

	// AuthSignature is the given signature (body + timestamp)
	AuthSignature = "x-auth-signature"

	// AuthHeaderHash hash of the body coming from the request
	AuthHeaderHash = "x-auth-hash"

	// AuthHeaderNonce random nonce for the request
	AuthHeaderNonce = "x-auth-nonce"

	// AuthHeaderTime the time of the request, only valid for 30 seconds
	AuthHeaderTime = "x-auth-time"

	// AuthSignatureTTL is the max TTL for a signature to be valid
	AuthSignatureTTL = 20 * time.Second
)
View Source
const (
	// DraftStatusDraft is when the transaction is a draft
	DraftStatusDraft string = "draft"

	// DraftStatusCanceled is when the draft is canceled
	DraftStatusCanceled string = "canceled"

	// DraftStatusExpired is when the draft has expired
	DraftStatusExpired string = "expired"

	// DraftStatusComplete is when the draft transaction is complete
	DraftStatusComplete string = "complete"
)
View Source
const UnknownErrorCode = "error-unknown"

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessKey

type AccessKey struct {
	// Model is a common model that contains common fields for all models.
	common.Model
	// ID is an hash of the compressed public key.
	ID string `json:"id" example:"874b86d6fd1d6c85a857e73180164203d8d23211bfd9d04d210f9f7fde5b82d8"`
	// XpubID is an access key's xpub related id.
	XpubID string `json:"xpub_id" example:"bb8593f85ef8056a77026ad415f02128f3768906de53e9e8bf8749fe2d66cf50"`
	// RevokedAt is a time when access key was revoked.
	RevokedAt *time.Time `json:"revoked_at,omitempty" example:"2024-02-26T11:02:28.069911Z"`
	// Key is a string representation of an access key.
	Key string `json:"key,omitempty" example:"3fd870d6bf1725f04084cf31209c04be5bd9bed001a390ad3bc632a55a3ee078"`
}

AccessKey is a model that represents an access key.

Example

ExampleAccessKey is an example for AccessKey model.

ac := new(AccessKey)
ac.Model.UpdatedAt = time.Now().UTC()
ac.Model.CreatedAt = time.Now().UTC()
deletedAt := time.Now().UTC()
ac.Model.DeletedAt = &deletedAt
ac.XpubID = "123"
ac.ID = "123"
fmt.Printf("%s", ac.ID)
Output:

123

type AdminStats

type AdminStats struct {
	// Balance is a total balance of all xpubs.
	Balance int64 `json:"balance"`
	// Destinations is a total number of destinations.
	Destinations int64 `json:"destinations"`
	// PaymailAddresses is a total number of paymail addresses.
	PaymailAddresses int64 `json:"paymail_addresses"`
	// Transactions is a total number of committed transactions.
	Transactions int64 `json:"transactions"`
	// TransactionsPerDay is a total number of committed transactions per day.
	TransactionsPerDay map[string]interface{} `json:"transactions_per_day"`
	// Utxos is a total number of utxos.
	Utxos int64 `json:"utxos"`
	// UtxosPerType are utxos grouped by type.
	UtxosPerType map[string]interface{} `json:"utxos_per_type"`
	// Xpubs is a total number of xpubs.
	XPubs int64 `json:"xpubs"`
}

AdminStats is a model that represents admin stats.

type AuthPayload

type AuthPayload struct {
	// AuthHash is the hash of the body contents
	AuthHash string `json:"auth_hash"`
	// AuthNonce is a random string
	AuthNonce string `json:"auth_nonce"`
	// AuthTime is the current time in milliseconds
	AuthTime int64 `json:"auth_time"`
	// BodyContents is the body of the request
	BodyContents string `json:"body_contents"`
	// Signature is the signature of the body contents
	Signature string `json:"signature"`
	// XPub is the xpub of the account
	XPub string `json:"xpub"`
	// AccessKey is the access key of the account
	AccessKey string `json:"access_key"`
}

AuthPayload is the struct that is used to create the signature for the API call

type BlockHeader

type BlockHeader struct {
	// Model is a common model that contains common fields for all models.
	common.Model

	// ID is a block header id (hash).
	ID string `json:"id"`
	// Height is a block header height.
	Height uint32 `json:"height"`
	// Time is a block header time (timestamp).
	Time uint32 `json:"time"`
	// Nonce is a block header nonce.
	Nonce uint32 `json:"nonce"`
	// Version is a block header version.
	Version uint32 `json:"version"`
	// HashPreviousBlock is a block header hash of previous block.
	HashPreviousBlock string `json:"hash_previous_block"`
	// HashMerkleRoot is a block header hash merkle tree root.
	HashMerkleRoot string `json:"hash_merkle_root"`
	// Bits contains BSV block header bits no.
	Bits string `json:"bits"`
	// Synec is a time when block header was synced.
	Synced time.Time `json:"synced"`
}

BlockHeader is a model that represents a BSV block header.

type Contact added in v0.19.0

type Contact struct {
	common.Model

	// ID is a unique identifier of contact.
	ID string `json:"id" example:"68af358bde7d8641621c7dd3de1a276c9a62cfa9e2d0740494519f1ba61e2f4a"`
	// FullName is name which could be shown instead of whole paymail address.
	FullName string `json:"fullName" example:"Test User"`
	// Paymail is a paymail address related to contact.
	Paymail string `json:"paymail" example:"test@spv-wallet.com"`
	// PubKey is a public key related to contact (receiver).
	PubKey string `json:"pubKey" example:"xpub661MyMwAqRbcGpZVrSHU..."`
	// Status is a contact's current status.
	Status ContactStatus `json:"status" example:"unconfirmed"`
}

type ContactStatus added in v0.19.0

type ContactStatus string
const (
	ContactNotConfirmed ContactStatus = "unconfirmed"
	ContactAwaitAccept  ContactStatus = "awaiting"
	ContactConfirmed    ContactStatus = "confirmed"
	ContactRejected     ContactStatus = "rejected"
)

type CreateContactResponse added in v0.25.0

type CreateContactResponse struct {
	Contact        *Contact          `json:"contact"`
	AdditionalInfo map[string]string `json:"additionalInfo"`
}

func (*CreateContactResponse) AddAdditionalInfo added in v0.25.0

func (m *CreateContactResponse) AddAdditionalInfo(k, v string)

type Destination

type Destination struct {
	// Model is a common model that contains common fields for all models.
	common.Model

	// ID is a destination id which is the hash of the LockingScript.
	ID string `json:"id" example:"82a5d848f997819a478b05fb713208d7f3aa66da5ba00953b9845fb1701f9b98"`
	// XpubID is a destination's xpub related id used to register destination.
	XpubID string `json:"xpub_id" example:"bb8593f85ef8056a77026ad415f02128f3768906de53e9e8bf8749fe2d66cf50"`
	// LockingScript is a destination's locking script.
	LockingScript string `json:"locking_script" example:"76a9147b05764a97f3b4b981471492aa703b188e45979b88ac"`
	// Type is a destination's type.
	Type string `json:"type" example:"pubkeyhash"`
	// Chain is a destination's chain representation.
	Chain uint32 `json:"chain" example:"0"`
	// Num is a destination's num representation.
	Num uint32 `json:"num" example:"0"`
	// PaymailExternalDerivationNum is the chain/num/(ext_derivation_num) location of the address related to the xPub.
	PaymailExternalDerivationNum *uint32 `json:"paymail_external_derivation_num" example:"0"`
	// Address is a destination's address.
	Address string `json:"address" example:"1CDUf7CKu8ocTTkhcYUbq75t14Ft168K65"`
	// DraftID is a destination's draft id.
	DraftID string `json:"draft_id" example:"b356f7fa00cd3f20cce6c21d704cd13e871d28d714a5ebd0532f5a0e0cde63f7"`
}

Destination is a model that represents a destination - registered in a spv-wallet with xpub.

type DraftTransaction

type DraftTransaction struct {
	// Model is a common model that contains common fields for all models.
	common.Model

	// ID is a draft transaction id.
	ID string `json:"id" example:"b356f7fa00cd3f20cce6c21d704cd13e871d28d714a5ebd0532f5a0e0cde63f7"`
	// Hex is a draft transaction hex.
	Hex string `json:"hex" example:"0100000002..."`
	// XpubID is a draft transaction's xpub used to sign transaction.
	XpubID string `json:"xpub_id" example:"bb8593f85ef8056a77026ad415f02128f3768906de53e9e8bf8749fe2d66cf50"`
	// ExpiresAt is a time when draft transaction expired.
	ExpiresAt time.Time `json:"expires_at" example:"2024-02-26T11:00:28.069911Z"`
	// Configuration contains draft transaction configuration.
	Configuration TransactionConfig `json:"configuration"`
	// Status is a draft transaction lastly monitored status.
	Status string `json:"status" example:"complete"`
	// FinalTxID is a final transaction id.
	FinalTxID string `json:"final_tx_id" example:"cfe30797f0b5fc098b32194e857569a7a1edd829fddf3df4567796b738de386d"`
}

DraftTransaction is a model that represents a draft transaction.

type Events added in v0.28.0

type Events interface {
	StringEvent | TransactionEvent
}

Events - interface for all supported events

type ExtendedError added in v0.28.0

type ExtendedError interface {
	error
	GetCode() string
	GetMessage() string
	GetStatusCode() int
}

type FeeUnit

type FeeUnit struct {
	// Satoshis is a fee unit satoshis amount.
	Satoshis int `json:"satoshis" example:"1"`
	// Bytes is a fee unit bytes representation.
	Bytes int `json:"bytes" example:"1000"`
}

FeeUnit is a model that represents a fee unit (simplified version of fee unit from go-bt).

type MapProtocol

type MapProtocol struct {
	// App is a map protocol app.
	App string `json:"app,omitempty"`
	// Keys is a map protocol keys.
	Keys map[string]interface{} `json:"keys,omitempty"`
	// Type is a map protocol type.
	Type string `json:"type,omitempty"`
}

MapProtocol is a model that represents a map protocol.

type Metadata

type Metadata map[string]interface{}

Metadata is a SPV Wallet ecosystem metadata model.

type OpReturn

type OpReturn struct {
	// Hex is a full hex of op return.
	Hex string `json:"hex,omitempty"`
	// HexParts is a slice of splitted hex parts.
	HexParts []string `json:"hex_parts,omitempty"`
	// Map is a pointer to a map protocol object.
	Map *MapProtocol `json:"map,omitempty"`
	// StringParts is a slice of string parts.
	StringParts []string `json:"string_parts,omitempty"`
}

OpReturn is a model that represents a op return.

type Page added in v0.28.0

type Page struct {
	// Field by which to order the results
	OrderByField *string `json:"orderByField"`
	// Direction in which to order the results ASC/DSC
	SortDirection *string `json:"sortDirection"`
	// Total count of elements
	TotalElements int64 `json:"totalElements"`
	// Total number of possible pages
	TotalPages int `json:"totalPages"`
	// Size of the page
	Size int `json:"size"`
	// Page number
	Number int `json:"number"`
}

Page object to use when limiting and sorting database query results

type PagedResponse added in v0.28.0

type PagedResponse[content any] struct {
	// List of records for the response
	Content []content `json:"content"`
	// Pagination details
	Page Page `json:"page"`
}

PagedResponse object to use when returning database records in paged format

type PaymailAddress

type PaymailAddress struct {
	// Model is a common model that contains common fields for all models.
	common.Model

	// ID is a paymail address id.
	ID string `json:"id" example:"c0ba4a52c89279268476a141be7569200cff2ca4892512b07ca75c25a95c16cd"`
	// XpubID is a paymail address's xpub related id used to register paymail address.
	XpubID string `json:"xpub_id" example:"bb8593f85ef8056a77026ad415f02128f3768906de53e9e8bf8749fe2d66cf50"`
	// Alias is a paymail address's alias (first part of paymail).
	Alias string `json:"alias" example:"test"`
	// Domain is a paymail address's domain (second part of paymail).
	Domain string `json:"domain" example:"spvwallet.com"`
	// PublicName is a paymail address's public name.
	PublicName string `json:"public_name" example:"Test User"`
	// Avatar is a paymail address's avatar.
	Avatar string `json:"avatar" example:"https://spvwallet.com/avatar.png"`
}

PaymailAddress is a model that represents a paymail address.

type PaymailP4

type PaymailP4 struct {
	// Alias is a paymail p4 alias.
	Alias string `json:"alias,omitempty"`
	// Domain is a paymail p4 domain.
	Domain string `json:"domain,omitempty"`
	// FromPaymail is a paymail p4 from paymail.
	FromPaymail string `json:"from_paymail,omitempty"`
	// Note is a paymail p4 note.
	Note string `json:"note,omitempty"`
	// PubKey is a paymail p4 pub key.
	PubKey string `json:"pub_key,omitempty"`
	// ReceiveEndpoint is a paymail p4 receive endpoint.
	ReceiveEndpoint string `json:"receive_endpoint,omitempty"`
	// ReferenceID is a paymail p4 reference id.
	ReferenceID string `json:"reference_id,omitempty"`
	// ResolutionType is a paymail p4 resolution type.
	ResolutionType string `json:"resolution_type,omitempty"`
}

PaymailP4 is a model that represents a paymail p4.

type RawEvent added in v0.28.0

type RawEvent struct {
	Type    string          `json:"type"`
	Content json.RawMessage `json:"content"`
}

RawEvent - the base event type

type ResponseError added in v0.28.0

type ResponseError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

ResponseError is an error which will be returned in HTTP response

type SPVError added in v0.28.0

type SPVError struct {
	Code       string
	Message    string
	StatusCode int
}

SPVError is extended error which holds information about http status and code that should be returned

func (SPVError) Error added in v0.28.0

func (e SPVError) Error() string

Error returns the error message string for SPVError, satisfying the error interface

func (SPVError) GetCode added in v0.28.0

func (e SPVError) GetCode() string

GetCode returns the error code string for SPVError

func (SPVError) GetMessage added in v0.28.0

func (e SPVError) GetMessage() string

GetMessage returns the error message string for SPVError

func (SPVError) GetStatusCode added in v0.28.0

func (e SPVError) GetStatusCode() int

GetStatusCode returns the error status code for SPVError

type ScriptOutput

type ScriptOutput struct {
	// Address is a script output address.
	Address string `json:"address,omitempty"`
	// Satoshis is a script output satoshis.
	Satoshis uint64 `json:"satoshis,omitempty"`
	// Script is a script output script.
	Script string `json:"script"`
	// ScriptType is a script output script type.
	ScriptType string `json:"script_type"`
}

ScriptOutput is a model that represents a script output.

type SearchContactsResponse added in v0.28.0

type SearchContactsResponse = PagedResponse[*Contact]

SearchContactsResponse is a response model for searching contacts

type SharedConfig added in v0.20.0

type SharedConfig struct {
	// PaymailDomains is a list of paymail domains handled by spv-wallet.
	PaymailDomains []string `json:"paymail_domains" example:"spv-wallet.com"`
	// ExperimentalFeatures is a map of experimental features handled by spv-wallet.
	ExperimentalFeatures map[string]bool `json:"experimental_features" example:"pike_enabled:true"`
}

SharedConfig with fields which can ba shared across the application components. Please be aware NOT to add ANY SENSITIVE information here.

type StringEvent added in v0.28.0

type StringEvent struct {
	Value string `json:"value"`
}

StringEvent - event with string value; can be used for generic messages and it's used for testing

type SubscribeRequestBody added in v0.28.0

type SubscribeRequestBody struct {
	URL         string `json:"url"`
	TokenHeader string `json:"tokenHeader"`
	TokenValue  string `json:"tokenValue"`
}

SubscribeRequestBody represents the request body for the subscribe endpoint.

type SyncConfig

type SyncConfig struct {
	// Broadcast is a flag that indicates whether to broadcast transaction or not.
	Broadcast bool `json:"broadcast"`
	// BroadcastInstant is a flag that indicates whether to broadcast transaction instantly or not.
	BroadcastInstant bool `json:"broadcast_instant"`
	// PaymailP2P is a flag that indicates whether to use paymail p2p or not.
	PaymailP2P bool `json:"paymail_p2p"`
	// SyncOnChain is a flag that indicates whether to sync transaction on chain or not.
	SyncOnChain bool `json:"sync_on_chain"`
}

SyncConfig contains sync configuration flags.

type SyncResult

type SyncResult struct {
	// Action type broadcast, sync etc
	Action string `json:"action"`
	// ExecutedAt contains time when action was executed.
	ExecutedAt time.Time `json:"executed_at"`
	// Provider field is used for attempts(s).
	Provider string `json:"provider,omitempty"`
	// StatusMessage contains success or failure messages.
	StatusMessage string `json:"status_message"`
}

SyncResult is a model that represents a single sync result.

type SyncResults

type SyncResults struct {
	// LastMessage is a last message received during sync.
	LastMessage string `json:"last_message"`
	// Results is a slice of sync results.
	Results []*SyncResult `json:"results"`
}

SyncResults is a model that represents a sync results.

type SyncTransaction

type SyncTransaction struct {
	// Model is a common model that contains common fields for all models.
	common.Model

	// ID is a sync transaction id.
	ID string `json:"id"`
	// Configuration contains sync transaction configuration.
	Configuration SyncConfig `json:"configuration"`
	// LastAttempt contains last attempt time.
	LastAttempt time.Time `json:"last_attempt"`
	// Results contains sync transaction results.
	Results SyncResults `json:"results"`
	// BroadcastStatus contains broadcast status.
	BroadcastStatus string `json:"broadcast_status"`
	// P2PStatus contains p2p status.
	P2PStatus string `json:"p2p_status"`
	// SyncStatus contains sync status.
	SyncStatus string `json:"sync_status"`
}

SyncTransaction is a model that represents a sync transaction specific fields.

type Transaction

type Transaction struct {
	// Model is a common model that contains common fields for all models.
	common.Model
	// ID is a transaction id.
	ID string `json:"id" example:"01d0d0067652f684c6acb3683763f353fce55f6496521c7d99e71e1d27e53f5c"`
	// Hex is a transaction hex.
	Hex string `json:"hex" example:"0100000002..."`
	// XpubInIDs is a slice of xpub input ids.
	XpubInIDs []string `json:"xpub_in_ids" example:"bb8593f85ef8056a77026ad415f02128f3768906de53e9e8bf8749fe2d66cf50"`
	// XpubOutIDs is a slice of xpub output ids.
	XpubOutIDs []string `json:"xpub_out_ids" example:"2075eca10bf2688b38cd7fdad6c24562463a9a26ae505d66c480fd53165dbaa2"`
	// BlockHash is a block hash that transaction is in.
	BlockHash string `json:"block_hash" example:"0000000000000000046e81025ca6cfbd2f45c7331f650c77edc99a14d5a1f0d0"`
	// BlockHeight is a block height that transaction is in.
	BlockHeight uint64 `json:"block_height" example:"833505"`
	// Fee is a transaction fee.
	Fee uint64 `json:"fee" example:"1"`
	// NumberOfInputs is a number of transaction inputs.
	NumberOfInputs uint32 `json:"number_of_inputs" example:"3"`
	// NumberOfOutputs is a number of transaction outputs.
	NumberOfOutputs uint32 `json:"number_of_outputs" example:"2"`
	// DraftID is a transaction related draft id.
	DraftID string `json:"draft_id" example:"b356f7fa00cd3f20cce6c21d704cd13e871d28d714a5ebd0532f5a0e0cde63f7"`
	// TotalValue is a total input value.
	TotalValue uint64 `json:"total_value" example:"51"`
	// OutputValue is a total output value.
	OutputValue int64 `json:"output_value,omitempty" example:"50"`
	// Outputs represents all spv-wallet-transaction outputs. Will be shown only for admin.
	Outputs map[string]int64 `` /* 171-byte string literal not displayed */
	// Status is a transaction status.
	Status string `json:"status" example:"MINED"`
	// TransactionDirection is a transaction direction (incoming/outgoing).
	TransactionDirection string `json:"direction" example:"outgoing"`
}

Transaction is a model that represents a transaction.

type TransactionConfig

type TransactionConfig struct {
	// ChangeDestinations is a slice of change destinations.
	ChangeDestinations []*Destination `json:"change_destinations"`
	// ChangeStrategy is a change strategy.
	ChangeStrategy string `json:"change_destinations_strategy"`
	// ChangeMinimumSatoshis is a minimum satoshis for change.
	ChangeMinimumSatoshis uint64 `json:"change_minimum_satoshis" example:"0"`
	// ChangeNumberOfDestinations is a number of change destinations.
	ChangeNumberOfDestinations int `json:"change_number_of_destinations" example:"1"`
	// ChangeSatoshis is a change satoshis.
	ChangeSatoshis uint64 `json:"change_satoshis" example:"49"`
	// ExpiresAt is a time when transaction expires.
	ExpiresIn time.Duration `json:"expires_in" example:"1000"`
	// Fee is a fee amount.
	Fee uint64 `json:"fee" example:"1"`
	// FeeUnit is a pointer to a fee unit object.
	FeeUnit *FeeUnit `json:"fee_unit"`
	// FromUtxos is a slice of from utxos used to build transaction.
	FromUtxos []*UtxoPointer `json:"from_utxos"`
	// IncludeUtxos is a slice of utxos to include in transaction.
	IncludeUtxos []*UtxoPointer `json:"include_utxos"`
	// Inputs is a slice of transaction inputs.
	Inputs []*TransactionInput `json:"inputs"`
	// Outputs is a slice of transaction outputs.
	Outputs []*TransactionOutput `json:"outputs"`
	// SendAllTo is a pointer to a transaction output object.
	SendAllTo *TransactionOutput `json:"send_all_to"`
	// Sync contains sync configuration.
	Sync *SyncConfig `json:"sync"`
}

TransactionConfig is a model that represents a transaction config.

type TransactionEvent added in v0.28.0

type TransactionEvent struct {
	UserEvent `json:",inline"`

	TransactionID string `json:"transactionId"`
	Status        string `json:"status"`
}

TransactionEvent - event for transaction changes

type TransactionInput

type TransactionInput struct {
	// Utxo is a pointer to a utxo object.
	Utxo `json:",inline"`
	// Destination is a pointer to a destination object.
	Destination Destination `json:"destination"`
}

TransactionInput is a model that represents a transaction input.

type TransactionOutput

type TransactionOutput struct {
	// OpReturn is a pointer to a op return object.
	OpReturn *OpReturn `json:"op_return,omitempty"`
	// PaymailP4 is a pointer to a paymail p4 object.
	PaymailP4 *PaymailP4 `json:"paymail_p4,omitempty"`
	// Satoshis is a satoshis amount.
	Satoshis uint64 `json:"satoshis" example:"50"`
	// Script is a transaction output string representation of script.
	Script string `json:"script" example:"76a91433ba3607a902bc022164bcb6e993f27bd040241c88ac"`
	// ScriptType is a transaction output script type.
	Scripts []*ScriptOutput `json:"scripts,omitempty"`
	// To is a transaction output destination address.
	To string `json:"to" example:"1MB8MfCyA5mGt3UBhxYr1exBfsFWgL1gCm"`
	// UseForChange is a flag that indicates if this output should be used for change.
	UseForChange bool `json:"use_for_change" example:"false"`
}

TransactionOutput is a model that represents a transaction output.

type UnsubscribeRequestBody added in v0.28.0

type UnsubscribeRequestBody struct {
	URL string `json:"url"`
}

UnsubscribeRequestBody represents the request body for the unsubscribe endpoint.

type UserEvent added in v0.28.0

type UserEvent struct {
	XPubID string `json:"xpubId"`
}

UserEvent - event with user identifier

type Utxo

type Utxo struct {
	// Model is a common model that contains common fields for all models.
	common.Model
	// UtxoPointer is a pointer to a utxo object.
	UtxoPointer `json:",inline"`

	// ID is a utxo id which is a hash from transaction id and output index.
	ID string `json:"id" example:"c706a448748d398d542cf4dfad797c9a4b123ebb72dbfb8b27f3d0f1dda99b58"`
	// XpubID is a utxo related xpub id.
	XpubID string `json:"xpub_id" example:"bb8593f85ef8056a77026ad415f02128f3768906de53e9e8bf8749fe2d66cf50"`
	// Satoshis is a utxo satoshis amount.
	Satoshis uint64 `json:"satoshis" example:"100"`
	// ScriptPubKey is a utxo script pub key.
	ScriptPubKey string `json:"script_pub_key" example:"76a91433ba3607a902bc022164bcb6e993f27bd040241c88ac"`
	// Type is a utxo type.
	Type string `json:"type" example:"pubkeyhash"`
	// DraftID is a utxo transaction related draft id.
	DraftID string `json:"draft_id" example:"b356f7fa00cd3f20cce6c21d704cd13e871d28d714a5ebd0532f5a0e0cde63f7"`
	// ReservedAt is a time utxo was reserved at.
	ReservedAt time.Time `json:"reserved_at"  example:"2024-02-26T11:00:28.069911Z"`
	// SpendingTxID is a spending transaction id - null if not spent yet.
	SpendingTxID string `json:"spending_tx_id" example:"01d0d0067652f684c6acb3683763f353fce55f6496521c7d99e71e1d27e53f5c"`
	// Transaction is a transaction pointer that utxo points to.
	Transaction *Transaction `json:"transaction"`
}

Utxo is a model that represents a utxo.

type UtxoPointer

type UtxoPointer struct {
	// TransactionID is a transaction id that utxo points to.
	TransactionID string `json:"transaction_id" example:"01d0d0067652f684c6acb3683763f353fce55f6496521c7d99e71e1d27e53f5c"`
	// OutputIndex is a output index that utxo points to.
	OutputIndex uint32 `json:"output_index" example:"0"`
}

UtxoPointer is a pointer model that represents a utxo.

type Xpub

type Xpub struct {
	// Model is a common model that contains common fields for all models.
	common.Model

	// ID is a hash of the xpub.
	ID string `json:"id" example:"bb8593f85ef8056a77026ad415f02128f3768906de53e9e8bf8749fe2d66cf50"`
	// CurrentBalance is a xpub's current balance.
	CurrentBalance uint64 `json:"current_balance" example:"1234"`
	// NextInternalNum is the index derivation number use to generate NEXT internal xPub (internal xPub are used for change destinations).
	NextInternalNum uint32 `json:"next_internal_num" example:"0"`
	// NextExternalNum is the index derivation number use to generate NEXT external xPub (external xPub are used for address destinations).
	NextExternalNum uint32 `json:"next_external_num" example:"0"`
}

Xpub is a model that represents a xpub.

type XpubMetadata

type XpubMetadata map[string]Metadata

XpubMetadata is a SPV Wallet ecosystem xpub metadata model.

Directories

Path Synopsis
Package common is a package that contains common models used by all other packages.
Package common is a package that contains common models used by all other packages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL