Documentation ¶
Overview ¶
Package cashu contains the core structs and logic of the Cashu protocol.
Index ¶
- Variables
- func AmountSplit(amount uint64) []uint64
- func CheckDuplicateProofs(proofs Proofs) bool
- func Count(amounts []uint64, amount uint64) uint
- func GenerateRandomQuoteId() (string, error)
- func Max(x, y uint64) uint64
- func SortBlindedMessages(blindedMessages BlindedMessages, secrets []string, rs []*secp256k1.PrivateKey)
- type BlindedMessage
- type BlindedMessages
- type BlindedSignature
- type BlindedSignatures
- type CashuErrCode
- type DLEQProof
- type DLEQV4
- type Error
- type Proof
- type ProofV4
- type Proofs
- type Token
- type TokenV3
- type TokenV3Proof
- type TokenV4
- type TokenV4Proof
- type Unit
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidTokenV3 = errors.New("invalid V3 token") ErrInvalidTokenV4 = errors.New("invalid V4 token") ErrInvalidUnit = errors.New("invalid unit") )
View Source
var ( StandardErr = Error{Detail: "mint is currently unable to process request", Code: StandardErrCode} EmptyBodyErr = Error{Detail: "request body cannot be emtpy", Code: StandardErrCode} UnknownKeysetErr = Error{Detail: "unknown keyset", Code: UnknownKeysetErrCode} PaymentMethodNotSupportedErr = Error{Detail: "payment method not supported", Code: PaymentMethodErrCode} UnitNotSupportedErr = Error{Detail: "unit not supported", Code: UnitErrCode} InvalidBlindedMessageAmount = Error{Detail: "invalid amount in blinded message", Code: StandardErrCode} BlindedMessageAlreadySigned = Error{Detail: "blinded message already signed", Code: BlindedMessageAlreadySignedErrCode} MintQuoteRequestNotPaid = Error{Detail: "quote request has not been paid", Code: MintQuoteRequestNotPaidErrCode} MintQuoteAlreadyIssued = Error{Detail: "quote already issued", Code: MintQuoteAlreadyIssuedErrCode} MintingDisabled = Error{Detail: "minting is disabled", Code: MintingDisabledErrCode} MintAmountExceededErr = Error{Detail: "max amount for minting exceeded", Code: AmountLimitExceeded} OutputsOverQuoteAmountErr = Error{Detail: "sum of the output amounts is greater than quote amount", Code: StandardErrCode} ProofAlreadyUsedErr = Error{Detail: "proof already used", Code: ProofAlreadyUsedErrCode} ProofPendingErr = Error{Detail: "proof is pending", Code: ProofAlreadyUsedErrCode} InvalidProofErr = Error{Detail: "invalid proof", Code: InvalidProofErrCode} NoProofsProvided = Error{Detail: "no proofs provided", Code: InvalidProofErrCode} DuplicateProofs = Error{Detail: "duplicate proofs", Code: InvalidProofErrCode} QuoteNotExistErr = Error{Detail: "quote does not exist", Code: MeltQuoteErrCode} MeltQuotePending = Error{Detail: "quote is pending", Code: MeltQuotePendingErrCode} MeltQuoteAlreadyPaid = Error{Detail: "quote already paid", Code: MeltQuoteAlreadyPaidErrCode} MeltAmountExceededErr = Error{Detail: "max amount for melting exceeded", Code: AmountLimitExceeded} MeltQuoteForRequestExists = Error{Detail: "melt quote for payment request already exists", Code: MeltQuoteErrCode} InsufficientProofsAmount = Error{ Detail: "amount of input proofs is below amount needed for transaction", Code: InsufficientProofAmountErrCode, } InactiveKeysetSignatureRequest = Error{Detail: "requested signature from inactive keyset", Code: InactiveKeysetErrCode} )
Functions ¶
func AmountSplit ¶
Given an amount, it returns list of amounts e.g 13 -> [1, 4, 8] that can be used to build blinded messages or split operations. from nutshell implementation
func CheckDuplicateProofs ¶ added in v0.2.0
func GenerateRandomQuoteId ¶ added in v0.2.0
func SortBlindedMessages ¶ added in v0.2.0
func SortBlindedMessages(blindedMessages BlindedMessages, secrets []string, rs []*secp256k1.PrivateKey)
Types ¶
type BlindedMessage ¶
type BlindedMessage struct { Amount uint64 `json:"amount"` B_ string `json:"B_"` Id string `json:"id"` Witness string `json:"witness,omitempty"` }
Cashu BlindedMessage. See https://github.com/cashubtc/nuts/blob/main/00.md#blindedmessage
func NewBlindedMessage ¶ added in v0.2.0
func NewBlindedMessage(id string, amount uint64, B_ *secp256k1.PublicKey) BlindedMessage
type BlindedMessages ¶
type BlindedMessages []BlindedMessage
func (BlindedMessages) Amount ¶ added in v0.2.0
func (bm BlindedMessages) Amount() uint64
type BlindedSignature ¶
type BlindedSignature struct { Amount uint64 `json:"amount"` C_ string `json:"C_"` Id string `json:"id"` // doing pointer here so that omitempty works. // an empty struct would still get marshalled DLEQ *DLEQProof `json:"dleq,omitempty"` }
Cashu BlindedSignature. See https://github.com/cashubtc/nuts/blob/main/00.md#blindsignature
type BlindedSignatures ¶
type BlindedSignatures []BlindedSignature
func (BlindedSignatures) Amount ¶ added in v0.3.0
func (bs BlindedSignatures) Amount() uint64
type CashuErrCode ¶
type CashuErrCode int
const ( StandardErrCode CashuErrCode = 10000 // These will never be returned in a response. // Using them to identify internally where // the error originated and log appropriately DBErrCode CashuErrCode = 1 LightningBackendErrCode CashuErrCode = 2 UnitErrCode CashuErrCode = 11005 PaymentMethodErrCode CashuErrCode = 11007 BlindedMessageAlreadySignedErrCode CashuErrCode = 10002 InvalidProofErrCode CashuErrCode = 10003 ProofAlreadyUsedErrCode CashuErrCode = 11001 InsufficientProofAmountErrCode CashuErrCode = 11002 UnknownKeysetErrCode CashuErrCode = 12001 InactiveKeysetErrCode CashuErrCode = 12002 AmountLimitExceeded CashuErrCode = 11006 MintQuoteRequestNotPaidErrCode CashuErrCode = 20001 MintQuoteAlreadyIssuedErrCode CashuErrCode = 20002 MintingDisabledErrCode CashuErrCode = 20003 MeltQuotePendingErrCode CashuErrCode = 20005 MeltQuoteAlreadyPaidErrCode CashuErrCode = 20006 LightningPaymentErrCode CashuErrCode = 20008 MeltQuoteErrCode CashuErrCode = 20009 )
Common error codes
type Error ¶
type Error struct { Detail string `json:"detail"` Code CashuErrCode `json:"code"` }
Error represents an error to be returned by the mint
func BuildCashuError ¶
func BuildCashuError(detail string, code CashuErrCode) *Error
type Proof ¶
type Proof struct { Amount uint64 `json:"amount"` Id string `json:"id"` Secret string `json:"secret"` C string `json:"C"` Witness string `json:"witness,omitempty"` // doing pointer here so that omitempty works. // an empty struct would still get marshalled DLEQ *DLEQProof `json:"dleq,omitempty"` }
Cashu Proof. See https://github.com/cashubtc/nuts/blob/main/00.md#proof
type Token ¶
Cashu token. See https://github.com/cashubtc/nuts/blob/main/00.md#token-format
func DecodeToken ¶
type TokenV3 ¶ added in v0.3.0
type TokenV3 struct { Token []TokenV3Proof `json:"token"` Unit string `json:"unit"` Memo string `json:"memo,omitempty"` }
func DecodeTokenV3 ¶ added in v0.3.0
func NewTokenV3 ¶ added in v0.3.0
type TokenV3Proof ¶ added in v0.3.0
type TokenV4 ¶ added in v0.3.0
type TokenV4 struct { TokenProofs []TokenV4Proof `json:"t"` Memo string `json:"d,omitempty"` MintURL string `json:"m"` Unit string `json:"u"` }
func DecodeTokenV4 ¶ added in v0.3.0
func NewTokenV4 ¶ added in v0.3.0
type TokenV4Proof ¶ added in v0.3.0
Directories ¶
Path | Synopsis |
---|---|
nuts
|
|
nut01
Package nut01 contains structs as defined in NUT-01
[NUT-01]: https://github.com/cashubtc/nuts/blob/main/01.md
|
Package nut01 contains structs as defined in NUT-01 [NUT-01]: https://github.com/cashubtc/nuts/blob/main/01.md |
nut02
Package nut02 contains structs as defined in NUT-02
[NUT-02]: https://github.com/cashubtc/nuts/blob/main/02.md
|
Package nut02 contains structs as defined in NUT-02 [NUT-02]: https://github.com/cashubtc/nuts/blob/main/02.md |
nut03
Package nut03 contains structs as defined in NUT-03
[NUT-03]: https://github.com/cashubtc/nuts/blob/main/03.md
|
Package nut03 contains structs as defined in NUT-03 [NUT-03]: https://github.com/cashubtc/nuts/blob/main/03.md |
nut04
Package nut04 contains structs as defined in NUT-04
[NUT-04]: https://github.com/cashubtc/nuts/blob/main/04.md
|
Package nut04 contains structs as defined in NUT-04 [NUT-04]: https://github.com/cashubtc/nuts/blob/main/04.md |
nut05
Package nut05 contains structs as defined in NUT-05
[NUT-05]: https://github.com/cashubtc/nuts/blob/main/05.md
|
Package nut05 contains structs as defined in NUT-05 [NUT-05]: https://github.com/cashubtc/nuts/blob/main/05.md |
nut06
Package nut06 contains structs as defined in NUT-06
[NUT-06]: https://github.com/cashubtc/nuts/blob/main/06.md
|
Package nut06 contains structs as defined in NUT-06 [NUT-06]: https://github.com/cashubtc/nuts/blob/main/06.md |
Click to show internal directories.
Click to hide internal directories.