lib

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

***************************************************************************

  • Copyright (C) 2023 CrowdWare *
  • This file is part of SHIFT. *
  • SHIFT is free software: you can redistribute it and/or modify
  • it under the terms of the GNU General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • SHIFT is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details. *
  • You should have received a copy of the GNU General Public License
  • along with SHIFT. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************

***************************************************************************

  • Copyright (C) 2023 CrowdWare *
  • This file is part of SHIFT. *
  • SHIFT is free software: you can redistribute it and/or modify
  • it under the terms of the GNU General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • SHIFT is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details. *
  • You should have received a copy of the GNU General Public License
  • along with SHIFT. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************

***************************************************************************

  • Copyright (C) 2023 CrowdWare *
  • This file is part of SHIFT. *
  • SHIFT is free software: you can redistribute it and/or modify
  • it under the terms of the GNU General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • SHIFT is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details. *
  • You should have received a copy of the GNU General Public License
  • along with SHIFT. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************

***************************************************************************

  • Copyright (C) 2023 CrowdWare *
  • This file is part of SHIFT. *
  • SHIFT is free software: you can redistribute it and/or modify
  • it under the terms of the GNU General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • SHIFT is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details. *
  • You should have received a copy of the GNU General Public License
  • along with SHIFT. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************

***************************************************************************

  • Copyright (C) 2023 CrowdWare *
  • This file is part of SHIFT. *
  • SHIFT is free software: you can redistribute it and/or modify
  • it under the terms of the GNU General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • SHIFT is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details. *
  • You should have received a copy of the GNU General Public License
  • along with SHIFT. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************

***************************************************************************

  • Copyright (C) 2023 CrowdWare *
  • This file is part of SHIFT. *
  • SHIFT is free software: you can redistribute it and/or modify
  • it under the terms of the GNU General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • SHIFT is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details. *
  • You should have received a copy of the GNU General Public License
  • along with SHIFT. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************

***************************************************************************

  • Copyright (C) 2023 CrowdWare *
  • This file is part of SHIFT. *
  • SHIFT is free software: you can redistribute it and/or modify
  • it under the terms of the GNU General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • SHIFT is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details. *
  • You should have received a copy of the GNU General Public License
  • along with SHIFT. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************

***************************************************************************

  • Copyright (C) 2023 CrowdWare *
  • This file is part of SHIFT. *
  • SHIFT is free software: you can redistribute it and/or modify
  • it under the terms of the GNU General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • SHIFT is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details. *
  • You should have received a copy of the GNU General Public License
  • along with SHIFT. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************

***************************************************************************

  • Copyright (C) 2023 CrowdWare *
  • This file is part of SHIFT. *
  • SHIFT is free software: you can redistribute it and/or modify
  • it under the terms of the GNU General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • SHIFT is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details. *
  • You should have received a copy of the GNU General Public License
  • along with SHIFT. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************

Index

Constants

View Source
const (
	Unknown        TransactionType = iota
	InitialBooking                 = 1
	Scooped                        = 2
	Lmp                            = 3 // liquid micro payment
	Lmr                            = 4 // liquid micro receive
	Subtotal                       = 5
)

Variables

This section is empty.

Functions

func AcceptProposal

func AcceptProposal() string

** When GetProposalFromQRCode is called, then this transaction is stored temporary ** In this method we take the last transaction and withdraw it from the account. ** We don't want to have a public function for adding transactions.

func AddPeerFromQRCode

func AddPeerFromQRCode(enc string) string

** Decrypt the QR-Code, unmarshalls the peer and add it to the peer list

func CanScoop

func CanScoop() bool

func CreateAccount

func CreateAccount(name, uuid, ruuid, country, language string) int

** Create the account and send it to the rest service. ** This is only called once running the app for the first time. ** The invite code may come as uuid or an encoded uuid.

func Decrypt

func Decrypt(enc string) (string, error)

func DeletePeerMassage

func DeletePeerMassage(peerUuid, messageKey string) bool

** Deletes a message from Storj

func Encrypt

func Encrypt(value string) string

func GetAccessToken

func GetAccessToken() string

** Return the Storj Access Token

func GetAgreementFromQRCode

func GetAgreementFromQRCode(enc string) string

** We encrypt the QR-Code, unpack and validate the transaction and when ** everything is fine we book it.

func GetAgreementQRCode

func GetAgreementQRCode() string

** Create a transation, pack it to a json string and return the encrypted string. ** On the client a QR code will be created based on that string.

func GetAgreementQRCodeForTransaction

func GetAgreementQRCodeForTransaction(pkey string) string

** Get a transaction from account, pack it to a json string and return the encrypted string. ** This is used in case the giver skipped the last step and wants to recreate the qr code.

func GetBalanceInMillis

func GetBalanceInMillis() int64

** Sum up all transactions after subtracting the demurrage.

func GetBucketName

func GetBucketName() string

** Returns the Storj Bucketname

func GetEncodedUuid

func GetEncodedUuid() string

func GetMatelist

func GetMatelist() string

** Get a list of all mates from rest service, pack them into json and return the json string. ** We are also adding the user from the peerlist. These are the users with whom we exchanged ** Our public key and storj access with.

func GetMessages

func GetMessages() string

** Get the messages from message.db ** TODO: Only return the last X newest messages ordered by time ** TODO: Paging, read first 50 messages, then read 51-100, and so forth ** TODO: Readed should be filled if receiver deleted the message

func GetName

func GetName() string

** Return the account Name

func GetPeerQRCode

func GetPeerQRCode() string

** Returns an encrypted record of the first Peer

func GetProposalFromQRCode

func GetProposalFromQRCode(enc string) string

** We decrypt the string from a QR code, unpack and validate the transaction ** and send back the json to the client (we cannot send objects to Kotlin). ** If it cannot be decrypted or unpacked its a sign for an attack.

func GetProposalQRCode

func GetProposalQRCode(amount int64, purpose string) string

** Create a transaction, pack it to a json string and return the encrypted string. ** On the client a QR code will be created based on that string.

func GetScoopedBalance

func GetScoopedBalance() int64

** Calculate the scooped amount which since last setScooping, to be displayed ** on the client while balance display is in milli liter mode.

func GetScoopingHours

func GetScoopingHours() float64

** Returns the amount of hours the account is scooping

func GetTransactions

func GetTransactions() string

** Get a list of the last 30 transactions, pack it into a json string and return it.

func GetUuid

func GetUuid() string

** Return the account Uuid

func HasJoined

func HasJoined() bool

** Checks if account has been created already.

func Init

func Init(filesDir string, useWS bool)

** Set the path where the db can be stored.

func IsScooping

func IsScooping() bool

** Checks if account is scooping and is already 20 hours ago. ** If so a new scooped transaction is added and isScooping is set to false. ** The function returns this isScooping flag.

func RefreshMessages

func RefreshMessages()

** Loading all new messages for each peer and save them in the database

func SendMessageToPeer

func SendMessageToPeer(peerUuid string, message string) string

** Puts an encrypted message on the Storj bucket from the peer

func SetName

func SetName(name string)

** Set the account Name

func SetStorj

func SetStorj(bucketName string, accessKey string) bool

** Saves the Storj Data

func SetUseWebService

func SetUseWebService(useWS bool)

** Inform the lib to use WS or not

func StartScooping

func StartScooping() int

** Set the account in scooping mode, scooping is set to now and rest method is called. ** The level counts will be set after the rest call.

Types

type BalanceError

type BalanceError struct {
	// contains filtered or unexported fields
}

func (*BalanceError) Error

func (e *BalanceError) Error() string

type Friend

type Friend struct {
	Name         string
	Scooping     bool
	Uuid         string
	Country      string
	FriendsCount int
	HasPeerData  bool
}

type MessageTO

type MessageTO struct {
	Key      string
	From     string
	PeerUuid string
	Message  string
	Time     string
	Read     bool
}

type TransactionTO

type TransactionTO struct {
	Pkey    string
	Amount  int64
	Date    int64
	From    string
	To      string
	Purpose string
	Typ     int
}

** This is needed to create a json string to be sent to the client.

type TransactionType

type TransactionType byte

Jump to

Keyboard shortcuts

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