Documentation ¶
Index ¶
- Constants
- Variables
- func AmountSplit(amount uint64) []uint64
- func DeriveKeysetId(keysets []Keyset) (string, error)
- func ExpiryTimeMinUnit(minutes int64) int64
- func Fees(proofs []Proof, keysets []Keyset) (int, error)
- func GenerateNonceHex() (string, error)
- func GetAmountsForKeysets() []uint64
- type ACTION_STATE
- type BasicKeysetResponse
- type BlindSignature
- type BlindSignatureDLEQ
- type BlindedMessage
- type CheckState
- type ContactInfo
- type ErrorCode
- type ErrorResponse
- type GetInfoResponse
- type KeysResponse
- type Keyset
- type KeysetMap
- type KeysetResponse
- type MeltRequestDB
- type MintError
- type MintRequestDB
- type PostCheckStateRequest
- type PostCheckStateResponse
- type PostMeltBolt11Request
- type PostMeltQuoteBolt11Options
- type PostMeltQuoteBolt11Request
- type PostMeltQuoteBolt11Response
- type PostMintBolt11Request
- type PostMintBolt11Response
- type PostMintQuoteBolt11Request
- type PostMintQuoteBolt11Response
- type PostRestoreRequest
- type PostRestoreResponse
- type PostSwapRequest
- type PostSwapResponse
- type Proof
- func (p *Proof) AddPreimage(preimage string) error
- func (p Proof) HashSecretToCurve() (Proof, error)
- func (p Proof) IsProofSpendConditioned(checkOutputs *bool) (bool, *SpendCondition, *Witness, error)
- func (p *Proof) Sign(privkey *secp256k1.PrivateKey) error
- func (p Proof) VerifyWitness(spendCondition *SpendCondition, witness *Witness, ...) (bool, error)
- type ProofState
- type Proofs
- type RecoverSigDB
- type Seed
- type SigFlag
- type SpendCondition
- func (sc *SpendCondition) MarshalJSON() ([]byte, error)
- func (sc *SpendCondition) String() (string, error)
- func (s *SpendCondition) UnmarshalJSON(b []byte) error
- func (sc *SpendCondition) VerifyPreimage(witness *Witness) error
- func (sc *SpendCondition) VerifySignatures(witness *Witness, message string) (bool, []*btcec.PublicKey, error)
- type SpendConditionData
- type SpendConditionType
- type SwapMintInfo
- type SwapMintMethod
- type Tags
- type TagsInfo
- type Unit
- type Witness
Constants ¶
View Source
const ( OUTPUT_BLINDED_MESSAGE_ALREADY_SIGNED = 10002 TOKEN_NOT_VERIFIED = 10003 TOKEN_ALREADY_SPENT = 11001 TRANSACTION_NOT_BALANCED = 11002 UNIT_NOT_SUPPORTED = 11005 INSUFICIENT_FEE = 11006 // AMOUNT_OUTSIDE_OF_LIMIT = 11006 OVERPAID_FEE = 11007 KEYSET_NOT_KNOW = 12001 INACTIVE_KEYSET = 12002 REQUEST_NOT_PAID = 20001 TOKEN_ALREADY_ISSUED = 20002 MINTING_DISABLED = 20003 QUOTE_PENDING = 20005 INVOICE_ALREADY_PAID = 20006 UNKNOWN = 99999 )
View Source
const ExpiryMinutesDefault int64 = 15
View Source
const MaxKeysetAmount int = 64
View Source
const (
MethodBolt11 = "bolt11"
)
Variables ¶
View Source
var ( ErrInvalidSpendCondition = errors.New("Invalid spend condition") ErrConvertSpendConditionToString = errors.New("Failed to convert spend condition to string") ErrInvalidTagName = errors.New("Invalid tag name") ErrConvertTagToString = errors.New("Failed to convert tag to string") ErrInvalidTagValue = errors.New("Invalid tag value") ErrInvalidSigFlag = errors.New("Invalid sig flag") ErrConvertSigFlagToString = errors.New("Failed to convert sig flag to string") ErrMalformedTag = errors.New("Malformed tag") ErrCouldNotParseSpendCondition = errors.New("Could not parse spend condition") ErrCouldNotParseWitness = errors.New("Could not parse witness") ErrEmptyWitness = errors.New("Witness is empty") ErrNoValidSignatures = errors.New("No valid signatures found") ErrNotEnoughSignatures = errors.New("Not enough signatures") ErrLocktimePassed = errors.New("Locktime has passed and no refund key was found") ErrInvalidHexPreimage = errors.New("Preimage is not a valid hex string") ErrInvalidPreimage = errors.New("Invalid preimage") )
View Source
var ( ErrCouldNotParseUnitString = errors.New("Could not parse unit string") ErrCouldNotEncryptSeed = errors.New("Could not encrypt seed") ErrCouldNotDecryptSeed = errors.New("Could not decrypt seed") ErrKeysetNotFound = errors.New("Keyset not found") ErrKeysetForProofNotFound = errors.New("Keyset for proof not found") AlreadyActiveProof = errors.New("Proof already being spent") AlreadyActiveQuote = errors.New("Quote already being spent") UsingInactiveKeyset = errors.New("Trying to use an inactive keyset") )
View Source
var AvailableSeeds []Unit = []Unit{Sat}
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 DeriveKeysetId ¶
func ExpiryTimeMinUnit ¶
func GenerateNonceHex ¶
func GetAmountsForKeysets ¶
func GetAmountsForKeysets() []uint64
Types ¶
type ACTION_STATE ¶
type ACTION_STATE string
const ( UNPAID ACTION_STATE = "UNPAID" PAID ACTION_STATE = "PAID" PENDING ACTION_STATE = "PENDING" ISSUED ACTION_STATE = "ISSUED" )
type BasicKeysetResponse ¶
type BlindSignature ¶
type BlindSignature struct { Amount uint64 `json:"amount"` Id string `json:"id"` C_ string `json:"C_"` Dleq *BlindSignatureDLEQ `json:"dleq"` }
func (*BlindSignature) GenerateDLEQ ¶
func (b *BlindSignature) GenerateDLEQ(B_ *secp256k1.PublicKey, a *secp256k1.PrivateKey) error
func (*BlindSignature) VerifyDLEQ ¶
func (b *BlindSignature) VerifyDLEQ( blindMessage *secp256k1.PublicKey, e *secp256k1.PrivateKey, s *secp256k1.PrivateKey, A *secp256k1.PublicKey, ) (bool, error)
R1 = s*G - e*A
R2 = s*B' - e*C' e == hash(R1,R2,A,C')
If true, a in A = a*G must be equal to a in C' = a*B'
type BlindSignatureDLEQ ¶
type BlindSignatureDLEQ struct { E *secp256k1.PrivateKey `json:"e"` S *secp256k1.PrivateKey `json:"s"` }
func (*BlindSignatureDLEQ) MarshalJSON ¶
func (b *BlindSignatureDLEQ) MarshalJSON() ([]byte, error)
func (*BlindSignatureDLEQ) UnmarshalJSON ¶
func (b *BlindSignatureDLEQ) UnmarshalJSON(data []byte) error
type BlindedMessage ¶
type BlindedMessage struct { Amount uint64 `json:"amount"` Id string `json:"id"` B_ string `json:"B_"` Witness string `json:"witness,omitempty" db:"witness"` }
func (BlindedMessage) GenerateBlindSignature ¶
func (b BlindedMessage) GenerateBlindSignature(k *secp256k1.PrivateKey) (BlindSignature, error)
func (BlindedMessage) VerifyBlindMessageSignature ¶
func (b BlindedMessage) VerifyBlindMessageSignature(pubkeys map[*btcec.PublicKey]bool) error
type CheckState ¶
type CheckState struct { Y string `json:"Y"` State ProofState `json:"state"` Witness *string `json:"witness,omitempty"` }
type ContactInfo ¶
type ErrorResponse ¶
type ErrorResponse struct { // integer code Code ErrorCode `json:"code"` // Human readable error Error string `json:"error"` // Extended explanation of error Detail *string `json:"detail"` }
func ErrorCodeToResponse ¶
func ErrorCodeToResponse(code ErrorCode, detail *string) ErrorResponse
type GetInfoResponse ¶
type GetInfoResponse struct { Name string `json:"name"` Version string `json:"version"` Pubkey string `json:"pubkey"` Description string `json:"description"` DescriptionLong string `json:"description_long"` Contact []ContactInfo `json:"contact"` Motd string `json:"motd"` Nuts map[string]any `json:"nuts"` }
type KeysResponse ¶
type KeysResponse map[string][]KeysetResponse
func OrderKeysetByUnit ¶
func OrderKeysetByUnit(keysets []Keyset) KeysResponse
type Keyset ¶
type Keyset struct { Id string `json:"id"` Active bool `json:"active" db:"active"` Unit string `json:"unit"` Amount uint64 `json:"amount"` PrivKey *secp256k1.PrivateKey `json:"priv_key"` CreatedAt int64 `json:"created_at"` InputFeePpk int `json:"input_fee_ppk"` }
func GenerateKeysets ¶
type KeysetResponse ¶
type MeltRequestDB ¶
type MeltRequestDB struct { Quote string `json:"quote"` Unit string `json:"unit"` Expiry int64 `json:"expiry"` Amount uint64 `json:"amount"` FeeReserve uint64 `json:"fee_reserve" db:"fee_reserve"` // Deprecated: Should be removed after all main wallets change to the new State format RequestPaid bool `json:"paid" db:"request_paid"` Request string `json:"request"` Melted bool `json:"melted"` State ACTION_STATE `json:"state"` PaymentPreimage string `json:"payment_preimage"` SeenAt int64 `json:"seen_at"` Mpp bool `json:"mpp"` }
func (*MeltRequestDB) GetPostMeltQuoteResponse ¶
func (meltRequest *MeltRequestDB) GetPostMeltQuoteResponse() PostMeltQuoteBolt11Response
type MintRequestDB ¶
type MintRequestDB struct { Quote string `json:"quote"` Request string `json:"request"` // Deprecated: Should be removed after all main wallets change to the new State format RequestPaid bool `json:"paid" db:"request_paid"` Expiry int64 `json:"expiry"` Unit string `json:"unit"` Minted bool `json:"minted"` State ACTION_STATE `json:"state"` SeenAt int64 `json:"seen_at"` }
func (*MintRequestDB) PostMintQuoteBolt11Response ¶
func (m *MintRequestDB) PostMintQuoteBolt11Response() PostMintQuoteBolt11Response
type PostCheckStateRequest ¶
type PostCheckStateRequest struct {
Ys []string `json:"Ys"`
}
type PostCheckStateResponse ¶
type PostCheckStateResponse struct {
States []CheckState `json:"states"`
}
type PostMeltBolt11Request ¶
type PostMeltBolt11Request struct { Quote string `json:"quote"` Inputs Proofs `json:"inputs"` Outputs []BlindedMessage `json:"outputs"` }
type PostMeltQuoteBolt11Request ¶
type PostMeltQuoteBolt11Request struct { Request string `json:"request"` Unit string `json:"unit"` Options PostMeltQuoteBolt11Options `json:"options"` }
func (PostMeltQuoteBolt11Request) IsMpp ¶
func (p PostMeltQuoteBolt11Request) IsMpp() uint64
type PostMeltQuoteBolt11Response ¶
type PostMeltQuoteBolt11Response struct { Quote string `json:"quote"` Amount uint64 `json:"amount"` FeeReserve uint64 `json:"fee_reserve"` // Deprecated: Should be removed after all main wallets change to the new State format Paid bool `json:"paid"` Expiry int64 `json:"expiry"` State ACTION_STATE `json:"state"` Change []BlindSignature `json:"change"` PaymentPreimage string `json:"payment_preimage"` }
type PostMintBolt11Request ¶
type PostMintBolt11Request struct { Quote string `json:"quote"` Outputs []BlindedMessage `json:"outputs"` }
type PostMintBolt11Response ¶
type PostMintBolt11Response struct {
Signatures []BlindSignature `json:"signatures"`
}
type PostMintQuoteBolt11Response ¶
type PostMintQuoteBolt11Response struct { Quote string `json:"quote"` Request string `json:"request"` // Deprecated: Should be removed after all main wallets change to the new State format RequestPaid bool `json:"paid" db:"request_paid"` Expiry int64 `json:"expiry"` Unit string `json:"unit"` Minted bool `json:"minted"` State ACTION_STATE `json:"state"` }
type PostRestoreRequest ¶
type PostRestoreRequest struct {
Outputs []BlindedMessage `json:"outputs"`
}
type PostRestoreResponse ¶
type PostRestoreResponse struct { Outputs []BlindedMessage `json:"outputs"` Signatures []BlindSignature `json:"signatures"` }
type PostSwapRequest ¶
type PostSwapRequest struct { Inputs Proofs `json:"inputs"` Outputs []BlindedMessage `json:"outputs"` }
type PostSwapResponse ¶
type PostSwapResponse struct {
Signatures []BlindSignature `json:"signatures"`
}
type Proof ¶
type Proof struct { Amount uint64 `json:"amount"` Id string `json:"id"` Secret string `json:"secret"` C string `json:"C" db:"c"` Y string `json:"Y" db:"y"` Witness string `json:"witness" db:"witness"` SeenAt int64 `json:"seen_at"` State ProofState `json:"state"` Quote *string `json:"quote" db:"quote"` }
func (*Proof) AddPreimage ¶
func (Proof) HashSecretToCurve ¶
func (Proof) IsProofSpendConditioned ¶
func (Proof) VerifyWitness ¶
type ProofState ¶
type ProofState string
const PROOF_PENDING ProofState = "PENDING"
const PROOF_SPENT ProofState = "SPENT"
const PROOF_UNSPENT ProofState = "UNSPENT"
type Proofs ¶
type Proofs []Proof
func (*Proofs) SetPendingAndQuoteRef ¶
func (*Proofs) SetProofsState ¶
func (p *Proofs) SetProofsState(state ProofState)
func (*Proofs) SetQuoteReference ¶
type RecoverSigDB ¶
type RecoverSigDB struct { Amount uint64 `json:"amount"` Id string `json:"id"` B_ string `json:"B_" db:"B_"` C_ string `json:"C_" db:"C_"` CreatedAt int64 `json:"created_at" db:"created_at"` }
func (RecoverSigDB) GetBlindSignature ¶
func (r RecoverSigDB) GetBlindSignature() BlindSignature
func (RecoverSigDB) GetBlindedMessage ¶
func (r RecoverSigDB) GetBlindedMessage() BlindedMessage
func (RecoverSigDB) GetSigAndMessage ¶
func (r RecoverSigDB) GetSigAndMessage() (BlindSignature, BlindedMessage)
type SpendCondition ¶
type SpendCondition struct { Type SpendConditionType Data SpendConditionData }
func (*SpendCondition) MarshalJSON ¶
func (sc *SpendCondition) MarshalJSON() ([]byte, error)
["P2PK",{"nonce":"3229136a6627050449e85dcdf90315f87519f172b2af80b2e1d460695db511ab","data":"0275c5c0ddafea52d669f09de48da03896d09962d6d4e545e94f573d52840f04ae"}]
func (*SpendCondition) String ¶
func (sc *SpendCondition) String() (string, error)
func (*SpendCondition) UnmarshalJSON ¶
func (s *SpendCondition) UnmarshalJSON(b []byte) error
func (*SpendCondition) VerifyPreimage ¶
func (sc *SpendCondition) VerifyPreimage(witness *Witness) error
func (*SpendCondition) VerifySignatures ¶
func (sc *SpendCondition) VerifySignatures(witness *Witness, message string) (bool, []*btcec.PublicKey, error)
type SpendConditionData ¶
type SpendConditionType ¶
type SpendConditionType int
const ( P2PK SpendConditionType = iota + 1 HTLC SpendConditionType = iota + 2 )
func (SpendConditionType) String ¶
func (sc SpendConditionType) String() (string, error)
func (*SpendConditionType) UnmarshalJSON ¶
func (sc *SpendConditionType) UnmarshalJSON(b []byte) error
type SwapMintInfo ¶
type SwapMintInfo struct { Methods *[]SwapMintMethod `json:"methods,omitempty"` Disabled *bool `json:"disabled,omitempty"` Supported *bool `json:"supported,omitempty"` }
type SwapMintMethod ¶
type TagsInfo ¶
type TagsInfo struct { Sigflag SigFlag Pubkeys []*btcec.PublicKey NSigs int Locktime int Refund []*btcec.PublicKey }
func (*TagsInfo) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.