bitsurance

package
v0.0.0-...-96555be Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBitsuranceId

func GetBitsuranceId(account accounts.Interface) (string, error)

GetBitsuranceId returns the BitsuranceId of a given account. The id is computed hashing with sha256 the P2WPKH xpub of the account, concatenated with a fixed salt. If a P2WPKH xpub can't be found in the account, empty string is returned.

func WidgetURL

func WidgetURL(devServer bool, lang string) string

WidgetURL returns the url for the Bitsurance widget for a given locale.

Types

type AccountDetails

type AccountDetails struct {
	AccountCode types.Code   `json:"code"`
	Status      DetailStatus `json:"status"`
	Details     struct {
		MaxCoverage          int    `json:"maxCoverage"`
		MaxCoverageFormatted string `json:"maxCoverageFormatted"`
		Currency             string `json:"currency"`
		// Support contains a link to the bitsurance support page relevant for the account
		Support string `json:"support"`
	} `json:"details"`
}

AccountDetails represents the response of the bitsurance server for a single account.

func LookupBitsuranceAccounts

func LookupBitsuranceAccounts(devServer bool, accounts []accounts.Interface, httpClient *http.Client) ([]AccountDetails, error)

LookupBitsuranceAccounts takes in input a slice of accounts. For each account, it interrogates the Bitsurance server and returns a map with the given accounts' codes as keys and the insurance details as value.

type DetailStatus

type DetailStatus string

DetailStatus is the status of the insurance contract. Possible values (from Bitsurance Api docs) are listed below.

const (
	// ActiveStatus - insurance coverage activated.
	ActiveStatus DetailStatus = "active"
	// ProcessingStatus -	when still in creation/checking phase (short time).
	ProcessingStatus DetailStatus = "processing"
	// RefusedStatus - application got refused.
	RefusedStatus DetailStatus = "refused"
	// WaitPaymentStatus - accepted, but waiting on first payment.
	WaitPaymentStatus DetailStatus = "waitpayment"
	// InactiveStatus - offer support link for more info (maybe missed payment).
	InactiveStatus DetailStatus = "inactive"
	// CanceledStatus - contract got canceled.
	CanceledStatus DetailStatus = "canceled"
)

Jump to

Keyboard shortcuts

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