| @@ -0,0 +1 @@ | |||
| /config.production.json | |||
| @@ -0,0 +1,38 @@ | |||
| package auth | |||
| import ( | |||
| "fmt" | |||
| "github.com/golang-jwt/jwt/v4" | |||
| "github.com/spf13/viper" | |||
| "net/http" | |||
| "strings" | |||
| ) | |||
| type Claims struct { | |||
| Username string `json:"username"` | |||
| Privileges uint `json:"privileges"` | |||
| jwt.RegisteredClaims | |||
| } | |||
| func GetUserClaims(r *http.Request) (rights *Claims, err error) { | |||
| var token *jwt.Token | |||
| authHeader := r.Header.Get("Authorization") | |||
| if authHeader == "" { | |||
| return nil, nil | |||
| } | |||
| claims := &Claims{} | |||
| _, t, _ := strings.Cut(r.Header.Get("Authorization"), "Bearer ") | |||
| token, _ = jwt.ParseWithClaims(t, claims, func(token *jwt.Token) (interface{}, error) { | |||
| if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { | |||
| return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) | |||
| } | |||
| return []byte(viper.GetString("app.secretKey")), nil | |||
| }) | |||
| if !token.Valid { | |||
| return nil, nil | |||
| } | |||
| return claims, nil | |||
| } | |||
| @@ -0,0 +1,22 @@ | |||
| { | |||
| "app": { | |||
| "secretKey": "", | |||
| "domains": [""], | |||
| "port": 0 | |||
| }, | |||
| "database": { | |||
| "host": "", | |||
| "port": 0, | |||
| "name": "", | |||
| "user": "", | |||
| "password": "", | |||
| "ssl": "" | |||
| }, | |||
| "hashing": { | |||
| "memory": 0, | |||
| "iterations": 0, | |||
| "parallelism": 0, | |||
| "saltLength": 0, | |||
| "keyLength": 0 | |||
| } | |||
| } | |||
| @@ -0,0 +1,77 @@ | |||
| package data | |||
| import ( | |||
| "fmt" | |||
| "github.com/spf13/viper" | |||
| "gorm.io/driver/postgres" | |||
| "gorm.io/gorm" | |||
| ) | |||
| type Bonus struct { | |||
| Goal float64 `json:"goal"` | |||
| Percent float64 `json:"percent"` | |||
| RewardFundID uint `json:"rewardFundID"` | |||
| } | |||
| type RewardFund struct { | |||
| gorm.Model | |||
| Asset string `json:"asset"` | |||
| FundWallet string `json:"fundWallet"` | |||
| FundSecret string `json:"fundSecret"` | |||
| IssuerWallet string `json:"issuerWallet"` | |||
| Memo string `json:"memo"` | |||
| Price float64 `json:"price"` | |||
| AmountGoal float64 `gorm:"type:decimal(19,7)" json:"amountGoal"` | |||
| MinContribution float64 `gorm:"type:decimal(19,7)" json:"minContribution"` | |||
| Contributions []Contribution `json:"contributions"` | |||
| Title string `gorm:"type:varchar(50)" json:"title"` | |||
| Description string `gorm:"type:text" json:"description"` | |||
| Bonuses []Bonus `json:"bonuses"` | |||
| } | |||
| type Contribution struct { | |||
| gorm.Model | |||
| Wallet string `json:"wallet"` | |||
| Amount float64 `gorm:"type:decimal(19,7)" json:"amount"` | |||
| TransactionID string `json:"transactionID"` | |||
| RewardFundID uint `json:"rewardFundID"` | |||
| Tags []AppliedTag `json:"tags"` | |||
| } | |||
| type Tag struct { | |||
| gorm.Model | |||
| Description string `json:"description"` | |||
| Active bool `json:"active"` | |||
| Contribution AppliedTag `json:"contribution"` | |||
| } | |||
| type AppliedTag struct { | |||
| gorm.Model | |||
| TagID uint `json:"tagID"` | |||
| ContributionID uint `json:"contributionID"` | |||
| } | |||
| type User struct { | |||
| gorm.Model | |||
| Username string `json:"username"` | |||
| Password string `json:"password"` | |||
| Privileges uint `json:"admin"` | |||
| } | |||
| var Db *gorm.DB | |||
| func InitializeDatabase() { | |||
| var err error | |||
| dcs := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%d sslmode=%s", | |||
| viper.GetString("database.host"), | |||
| viper.GetString("database.user"), | |||
| viper.GetString("database.password"), | |||
| viper.GetString("database.name"), | |||
| viper.GetInt("database.port"), | |||
| viper.GetString("database.ssl")) | |||
| Db, err = gorm.Open(postgres.Open(dcs), &gorm.Config{}) | |||
| err = Db.AutoMigrate(User{}, RewardFund{}, Contribution{}, Bonus{}) | |||
| if err != nil { | |||
| panic("Could not migrate database") | |||
| } | |||
| } | |||
| @@ -0,0 +1,42 @@ | |||
| package endpoints | |||
| import ( | |||
| "encoding/json" | |||
| "github.com/imosed/signet/auth" | |||
| . "github.com/imosed/signet/data" | |||
| "net/http" | |||
| ) | |||
| type CloseRewardFundRequest struct { | |||
| ID uint `json:"id"` | |||
| Close bool `json:"close"` | |||
| } | |||
| func CloseRewardFund(w http.ResponseWriter, r *http.Request) { | |||
| var req CloseRewardFundRequest | |||
| err := json.NewDecoder(r.Body).Decode(&req) | |||
| if err != nil { | |||
| panic("Could not decode body") | |||
| } | |||
| var claims *auth.Claims | |||
| claims, err = auth.GetUserClaims(r) | |||
| if err != nil { | |||
| panic("Could not determine if user is authenticated") | |||
| } | |||
| var fund RewardFund | |||
| var modified int64 | |||
| if claims.Privileges <= AdminPlus && req.Close { | |||
| Db.Table("reward_funds").Find(&fund, req.ID) | |||
| modified = Db.Delete(&fund).RowsAffected | |||
| } | |||
| var resp SuccessResponse | |||
| resp.Success = modified > 0 | |||
| err = json.NewEncoder(w).Encode(resp) | |||
| if err != nil { | |||
| panic("Could not deliver response") | |||
| } | |||
| } | |||
| @@ -0,0 +1,93 @@ | |||
| package endpoints | |||
| import ( | |||
| "encoding/json" | |||
| "fmt" | |||
| . "github.com/imosed/signet/data" | |||
| "github.com/stellar/go/clients/horizonclient" | |||
| "github.com/stellar/go/keypair" | |||
| "github.com/stellar/go/network" | |||
| "github.com/stellar/go/protocols/horizon" | |||
| "github.com/stellar/go/txnbuild" | |||
| "net/http" | |||
| "strings" | |||
| ) | |||
| type ContributeRequest struct { | |||
| PrivateKey string `json:"privateKey"` | |||
| Amount float64 `json:"amount"` | |||
| RewardFund uint `json:"rewardFund"` | |||
| } | |||
| func Contribute(resp http.ResponseWriter, req *http.Request) { | |||
| var cont ContributeRequest | |||
| err := json.NewDecoder(req.Body).Decode(&cont) | |||
| if err != nil { | |||
| panic("Could not read in contribution") | |||
| } | |||
| var fund RewardFund | |||
| Db.Table("reward_funds").Select("id", "fund_wallet", "memo", "min_contribution").First(&fund, cont.RewardFund) | |||
| if cont.Amount < fund.MinContribution || !strings.HasPrefix(cont.PrivateKey, "S") { | |||
| err = json.NewEncoder(resp).Encode(&SuccessResponse{Success: false}) | |||
| if err != nil { | |||
| panic("Could not deliver unsuccessful contribution response") | |||
| } | |||
| return | |||
| } | |||
| source := keypair.MustParseFull(cont.PrivateKey) | |||
| sourceReq := horizonclient.AccountRequest{AccountID: source.Address()} | |||
| var sourceAcct horizon.Account | |||
| sourceAcct, err = client.AccountDetail(sourceReq) | |||
| if err != nil { | |||
| panic("Horizon client: could not get account details") | |||
| } | |||
| tx, err := txnbuild.NewTransaction( | |||
| txnbuild.TransactionParams{ | |||
| SourceAccount: &sourceAcct, | |||
| IncrementSequenceNum: true, | |||
| Operations: []txnbuild.Operation{ | |||
| &txnbuild.Payment{ | |||
| Destination: fund.FundWallet, | |||
| Amount: fmt.Sprintf("%f", cont.Amount), | |||
| Asset: txnbuild.NativeAsset{}, | |||
| SourceAccount: source.Address(), | |||
| }, | |||
| }, | |||
| BaseFee: txnbuild.MinBaseFee, | |||
| Memo: txnbuild.Memo(txnbuild.MemoText(fund.Memo)), | |||
| Preconditions: txnbuild.Preconditions{ | |||
| TimeBounds: txnbuild.NewInfiniteTimeout(), | |||
| }, | |||
| }) | |||
| if err != nil { | |||
| panic("Could not create contribution transaction") | |||
| } | |||
| tx, err = tx.Sign(network.TestNetworkPassphrase, source) | |||
| if err != nil { | |||
| panic("Could not sign contribution transaction") | |||
| } | |||
| var response horizon.Transaction | |||
| response, err = client.SubmitTransaction(tx) | |||
| if err != nil { | |||
| panic("Could not submit contribution transaction") | |||
| } | |||
| fmt.Println("Successful Transaction:") | |||
| fmt.Println("Ledger:", response.Ledger) | |||
| fmt.Println("Hash:", response.Hash) | |||
| var result SuccessResponse | |||
| result.Success = response.Successful && err == nil | |||
| err = json.NewEncoder(resp).Encode(&result) | |||
| if err != nil { | |||
| panic("Could not create response for new contribution") | |||
| } | |||
| } | |||
| @@ -0,0 +1,106 @@ | |||
| package endpoints | |||
| import ( | |||
| "fmt" | |||
| "github.com/gorilla/websocket" | |||
| . "github.com/imosed/signet/data" | |||
| "github.com/spf13/viper" | |||
| "github.com/stellar/go/clients/horizonclient" | |||
| "github.com/stellar/go/protocols/horizon" | |||
| "github.com/stellar/go/protocols/horizon/operations" | |||
| "golang.org/x/net/context" | |||
| "gorm.io/gorm" | |||
| "net/http" | |||
| "strconv" | |||
| "strings" | |||
| ) | |||
| var upgrader = websocket.Upgrader{ | |||
| ReadBufferSize: 1024, | |||
| WriteBufferSize: 1024, | |||
| CheckOrigin: func(r *http.Request) bool { | |||
| origin := r.Header.Get("Origin") | |||
| for _, domain := range viper.GetStringSlice("app.domains") { | |||
| if !strings.HasPrefix(origin, domain) { | |||
| continue | |||
| } | |||
| return true | |||
| } | |||
| return false | |||
| }, | |||
| } | |||
| var wsConn *websocket.Conn | |||
| func ContributorStream(resp http.ResponseWriter, req *http.Request) { | |||
| var err error | |||
| wsConn, err = upgrader.Upgrade(resp, req, nil) | |||
| if err != nil { | |||
| panic("Could not establish websocket connection") | |||
| } | |||
| } | |||
| func InitializeContributionStream() { | |||
| var err error | |||
| var wallets []struct { | |||
| FundWallet string | |||
| } | |||
| Db.Table("reward_funds").Select("fund_wallet").Scan(&wallets) | |||
| contributionUpdateHandler := func(op operations.Operation) { | |||
| payment := op.(operations.Payment) | |||
| var tx horizon.Transaction | |||
| var amt float64 | |||
| var fund RewardFund | |||
| tx, err = client.TransactionDetail(payment.GetTransactionHash()) | |||
| if err != nil { | |||
| panic("Could not get transaction from hash") | |||
| } | |||
| amt, err = strconv.ParseFloat(payment.Amount, 64) | |||
| if err != nil { | |||
| panic("Could not convert payment to float") | |||
| } | |||
| if tx.Memo == "" { | |||
| return | |||
| } | |||
| Db.Table("reward_funds").Select("id").Where("memo = ? and fund_wallet = ?", tx.Memo, payment.To).First(&fund) | |||
| contribution := Contribution{ | |||
| Model: gorm.Model{ | |||
| CreatedAt: tx.LedgerCloseTime, | |||
| }, | |||
| Wallet: payment.From, | |||
| Amount: amt, | |||
| TransactionID: payment.GetTransactionHash(), | |||
| RewardFundID: fund.ID, | |||
| } | |||
| if wsConn != nil { | |||
| err = wsConn.WriteJSON(contribution) | |||
| if err != nil { | |||
| panic("Unable to write json to contribution stream") | |||
| } | |||
| } else { | |||
| fmt.Println("No websocket connections") | |||
| } | |||
| Db.Table("contributions").Create(&contribution) | |||
| } | |||
| for _, wallet := range wallets { | |||
| opReq := horizonclient.OperationRequest{ | |||
| ForAccount: wallet.FundWallet, | |||
| Cursor: "now", | |||
| IncludeFailed: false, | |||
| } | |||
| opReq.SetOperationsEndpoint() | |||
| ctx, _ := context.WithCancel(context.Background()) // TODO: what is cancelFunc? | |||
| err = client.StreamOperations(ctx, opReq, contributionUpdateHandler) | |||
| if err != nil { | |||
| panic(err.Error()) | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,101 @@ | |||
| package endpoints | |||
| import ( | |||
| "encoding/json" | |||
| "fmt" | |||
| "github.com/imosed/signet/auth" | |||
| . "github.com/imosed/signet/data" | |||
| "github.com/stellar/go/clients/horizonclient" | |||
| "github.com/stellar/go/protocols/horizon" | |||
| "net/http" | |||
| "strconv" | |||
| ) | |||
| type SuccessResponse struct { | |||
| Success bool `json:"success"` | |||
| } | |||
| func CreateRewardFund(resp http.ResponseWriter, req *http.Request) { | |||
| var fund RewardFund | |||
| dec := json.NewDecoder(req.Body) | |||
| err := dec.Decode(&fund) | |||
| if err != nil { | |||
| panic("Could not read submitted reward fund") | |||
| } | |||
| var bonuses []Bonus | |||
| rewardFund := RewardFund{ | |||
| Asset: fund.Asset, | |||
| FundWallet: fund.FundWallet, | |||
| IssuerWallet: fund.IssuerWallet, | |||
| Memo: fund.Memo, | |||
| Price: 0, | |||
| AmountGoal: fund.AmountGoal, | |||
| MinContribution: fund.MinContribution, | |||
| Title: fund.Title, | |||
| Description: fund.Description, | |||
| Contributions: nil, | |||
| } | |||
| offerReq := horizonclient.OfferRequest{ | |||
| Seller: rewardFund.IssuerWallet, | |||
| Selling: fmt.Sprintf("%s:%s", rewardFund.Asset, rewardFund.IssuerWallet), | |||
| Buying: fmt.Sprintf("XLM:%s", rewardFund.IssuerWallet), | |||
| Order: horizonclient.OrderDesc, | |||
| } | |||
| op, err := client.Offers(offerReq) | |||
| if err != nil { | |||
| panic("Could not get offers") | |||
| } | |||
| offers := op.Embedded.Records | |||
| var price float64 | |||
| if len(offers) == 1 { | |||
| price, err = strconv.ParseFloat(op.Embedded.Records[0].Price, 64) | |||
| if err != nil { | |||
| panic("Could not parse price to float") | |||
| } | |||
| rewardFund.Price = price | |||
| } else { | |||
| var maxOffers float64 = 0 | |||
| var correctOffer horizon.Offer | |||
| for _, o := range op.Embedded.Records { | |||
| parsedAmt, err := strconv.ParseFloat(o.Amount, 64) | |||
| if err != nil { | |||
| panic("Could not parse amount to float") | |||
| } | |||
| if parsedAmt > maxOffers { | |||
| correctOffer = o | |||
| maxOffers = parsedAmt | |||
| } | |||
| } | |||
| price, err = strconv.ParseFloat(correctOffer.Price, 64) | |||
| if err != nil { | |||
| panic("Could not parse price to float") | |||
| } | |||
| rewardFund.Price = price | |||
| } | |||
| var claims *auth.Claims | |||
| claims, err = auth.GetUserClaims(req) | |||
| if err != nil { | |||
| panic("Could not determine if user is authenticated") | |||
| } | |||
| if claims.Privileges <= Admin { | |||
| Db.Create(&rewardFund) | |||
| for _, bonus := range fund.Bonuses { | |||
| bonus.RewardFundID = rewardFund.ID | |||
| bonuses = append(bonuses, bonus) | |||
| } | |||
| Db.Create(&bonuses) | |||
| err = json.NewEncoder(resp).Encode(&SuccessResponse{Success: true}) | |||
| if err != nil { | |||
| panic("Could not create response for created reward fund") | |||
| } | |||
| } else { | |||
| resp.WriteHeader(403) | |||
| } | |||
| } | |||
| @@ -0,0 +1,49 @@ | |||
| package endpoints | |||
| import ( | |||
| "encoding/json" | |||
| "github.com/imosed/signet/auth" | |||
| . "github.com/imosed/signet/data" | |||
| "net/http" | |||
| ) | |||
| type EscalatePrivilegesRequest struct { | |||
| Username string | |||
| } | |||
| func EscalatePrivileges(w http.ResponseWriter, r *http.Request) { | |||
| var req EscalatePrivilegesRequest | |||
| err := json.NewDecoder(r.Body).Decode(&req) | |||
| if err != nil { | |||
| panic("Could not decode body") | |||
| } | |||
| var resp SuccessResponse | |||
| var user User | |||
| var claims *auth.Claims | |||
| claims, err = auth.GetUserClaims(r) | |||
| if claims.Privileges == SuperUser { | |||
| Db.Table("users").Where("username = ?", req.Username).Find(&user) | |||
| if user.Privileges == SuperUser || user.Privileges == AdminPlus { | |||
| resp.Success = false | |||
| err = json.NewEncoder(w).Encode(resp) | |||
| if err != nil { | |||
| panic("Could not deliver failed escalate privileges response") | |||
| } | |||
| return | |||
| } | |||
| user.Privileges = AdminPlus | |||
| resp.Success = true | |||
| } else { | |||
| resp.Success = false | |||
| } | |||
| err = json.NewEncoder(w).Encode(resp) | |||
| if err != nil { | |||
| panic("Could not deliver successful escalate privileges response") | |||
| } | |||
| } | |||
| @@ -0,0 +1,152 @@ | |||
| package endpoints | |||
| import ( | |||
| "encoding/json" | |||
| . "github.com/imosed/signet/data" | |||
| "gorm.io/gorm/clause" | |||
| "net/http" | |||
| "time" | |||
| ) | |||
| type Total struct { | |||
| AmountHeld float64 `json:"amountHeld"` | |||
| } | |||
| type GetRewardFundRequest struct { | |||
| Id uint `json:"id"` | |||
| ConsolidateContributions bool `json:"consolidateContributions"` | |||
| } | |||
| type GetRewardFundResponse struct { | |||
| FundInfo FundInfo `json:"fundInfo"` | |||
| Contributions Contributions `json:"contributions"` | |||
| Total Total `json:"total"` | |||
| } | |||
| func GetRewardFund(resp http.ResponseWriter, req *http.Request) { | |||
| var fund RewardFund | |||
| var contribs Contributions | |||
| var amountHeld Total | |||
| var requestedFund GetRewardFundRequest | |||
| dec := json.NewDecoder(req.Body) | |||
| err := dec.Decode(&requestedFund) | |||
| if err != nil { | |||
| panic("Could not read requested fund") | |||
| } | |||
| found := Db.Preload(clause.Associations).Find(&fund, requestedFund.Id).RowsAffected | |||
| if found == 0 { | |||
| resp.WriteHeader(404) | |||
| return | |||
| } | |||
| Db.Table("contributions").Select("distinct on (created_at::TIMESTAMP::DATE) created_at").Where("reward_fund_id = ?", fund.ID).Scan(&contribs.Dates) | |||
| baseQuery := Db.Table("contributions").Where("reward_fund_id = ?", fund.ID).Limit(12) // TODO: change value | |||
| baseCount := Db.Table("contributions").Where("reward_fund_id = ?", fund.ID) | |||
| Db.Table("contributions").Select("sum(amount) amount_held").Where("reward_fund_id = ?", fund.ID).Scan(&amountHeld) | |||
| if requestedFund.ConsolidateContributions { | |||
| baseQuery.Select("wallet, sum(amount) amount").Group("wallet").Order("wallet").Scan(&contribs.List) | |||
| baseCount.Group("wallet").Count(&contribs.Total) | |||
| } else { | |||
| baseQuery.Select("wallet, amount, created_at").Order("created_at desc").Scan(&contribs.List) | |||
| baseCount.Count(&contribs.Total) | |||
| } | |||
| r := GetRewardFundResponse{ | |||
| FundInfo: FundInfo{ | |||
| ID: fund.ID, | |||
| CreatedAt: fund.CreatedAt, | |||
| Asset: fund.Asset, | |||
| FundWallet: fund.FundWallet, | |||
| IssuerWallet: fund.IssuerWallet, | |||
| Memo: fund.Memo, | |||
| Price: fund.Price, | |||
| AmountGoal: fund.AmountGoal, | |||
| MinContribution: fund.MinContribution, | |||
| Title: fund.Title, | |||
| Description: fund.Description, | |||
| Bonuses: fund.Bonuses, | |||
| }, | |||
| Contributions: contribs, | |||
| Total: amountHeld, | |||
| } | |||
| err = json.NewEncoder(resp).Encode(r) | |||
| if err != nil { | |||
| panic("Could not deliver requested fund") | |||
| } | |||
| } | |||
| type GetContributionsRequest struct { | |||
| Id uint `json:"id"` | |||
| Offset int `json:"offset"` | |||
| ForDate string `json:"forDate"` | |||
| ConsolidateContributions bool `json:"consolidateContributions"` | |||
| } | |||
| type Contributions struct { | |||
| List []Contribution `json:"list"` | |||
| Dates []string `json:"dates"` | |||
| Total int64 `json:"total"` | |||
| } | |||
| type GetContributionsResponse = Contributions | |||
| func GetContributions(w http.ResponseWriter, r *http.Request) { | |||
| var req GetContributionsRequest | |||
| err := json.NewDecoder(r.Body).Decode(&req) | |||
| if err != nil { | |||
| panic("Could not decode body") | |||
| } | |||
| var resp GetContributionsResponse | |||
| baseQuery := Db.Table("contributions").Where("reward_fund_id = ?", req.Id).Offset(req.Offset).Limit(12) // TODO: change value | |||
| baseCount := Db.Table("contributions").Where("reward_fund_id = ?", req.Id) | |||
| Db.Table("contributions").Select("distinct on (created_at::TIMESTAMP::DATE) created_at").Where("reward_fund_id = ?", req.Id).Scan(&resp.Dates) | |||
| if req.ForDate == "" { | |||
| if req.ConsolidateContributions { | |||
| baseQuery.Select("wallet, sum(amount) amount").Group("wallet").Scan(&resp.List) | |||
| baseCount.Group("wallet").Count(&resp.Total) | |||
| } else { | |||
| baseQuery.Select("wallet, amount, created_at").Order("created_at desc").Scan(&resp.List) | |||
| baseCount.Count(&resp.Total) | |||
| } | |||
| } else { | |||
| var t time.Time | |||
| t, err = time.Parse("2006-Jan-02", req.ForDate) | |||
| t = t.Add(time.Hour * 24) | |||
| if err != nil { | |||
| panic("Could not interpret time") | |||
| } | |||
| if req.ConsolidateContributions { | |||
| baseQuery.Select("wallet, sum(amount) amount").Where("created_at < ?", t).Group("wallet").Scan(&resp.List) | |||
| baseCount.Where("created_at < ?", t).Group("wallet").Count(&resp.Total) | |||
| } else { | |||
| baseQuery.Select("wallet, amount, created_at").Where("created_at < ?", t).Order("created_at desc").Scan(&resp.List) | |||
| baseCount.Where("created_at < ?", t).Count(&resp.Total) | |||
| } | |||
| } | |||
| err = json.NewEncoder(w).Encode(resp) | |||
| if err != nil { | |||
| panic("Could not deliver response") | |||
| } | |||
| } | |||
| type FundInfo struct { | |||
| ID uint `json:"id"` | |||
| CreatedAt time.Time `json:"createdAt"` | |||
| Asset string `json:"asset"` | |||
| FundWallet string `json:"fundWallet"` | |||
| IssuerWallet string `json:"issuerWallet"` | |||
| Memo string `json:"memo"` | |||
| Price float64 `json:"price"` | |||
| AmountGoal float64 `json:"amountGoal"` | |||
| MinContribution float64 `json:"minContribution"` | |||
| Title string `json:"title"` | |||
| Description string `json:"description"` | |||
| Bonuses []Bonus `json:"bonuses"` | |||
| } | |||
| @@ -0,0 +1,54 @@ | |||
| package endpoints | |||
| import ( | |||
| "encoding/json" | |||
| . "github.com/imosed/signet/data" | |||
| "gorm.io/gorm/clause" | |||
| "net/http" | |||
| ) | |||
| func GetRewardFunds(w http.ResponseWriter, r *http.Request) { | |||
| var req GetRewardFundsRequest | |||
| err := json.NewDecoder(r.Body).Decode(&req) | |||
| if err != nil { | |||
| panic("Could not decode body") | |||
| } | |||
| var resp GetRewardFundsResponse | |||
| var rewardFunds []RewardFund | |||
| Db.Table("reward_funds").Count(&resp.Total) | |||
| Db.Preload(clause.Associations).Table("reward_funds"). | |||
| Select("id", "created_at", "asset", "fund_wallet", "issuer_wallet", "memo", "amount_goal", "min_contribution", "close_time", "title"). | |||
| Order("created_at desc"). | |||
| Find(&rewardFunds) | |||
| for _, f := range rewardFunds { | |||
| resp.RewardFunds = append(resp.RewardFunds, FundInfo{ | |||
| ID: f.ID, | |||
| CreatedAt: f.CreatedAt, | |||
| Asset: f.Asset, | |||
| FundWallet: f.FundWallet, | |||
| IssuerWallet: f.IssuerWallet, | |||
| Memo: f.Memo, | |||
| AmountGoal: f.AmountGoal, | |||
| MinContribution: f.MinContribution, | |||
| Title: f.Title, | |||
| Description: f.Description, | |||
| Bonuses: f.Bonuses, | |||
| }) | |||
| } | |||
| err = json.NewEncoder(w).Encode(resp) | |||
| if err != nil { | |||
| panic("Could not deliver response") | |||
| } | |||
| } | |||
| type GetRewardFundsRequest struct { | |||
| Offset int `json:"offset"` | |||
| } | |||
| type GetRewardFundsResponse struct { | |||
| RewardFunds []FundInfo `json:"rewardFunds"` | |||
| Total int64 `json:"total"` | |||
| } | |||
| @@ -0,0 +1,63 @@ | |||
| package endpoints | |||
| import ( | |||
| "encoding/json" | |||
| "github.com/golang-jwt/jwt/v4" | |||
| "github.com/imosed/signet/auth" | |||
| . "github.com/imosed/signet/data" | |||
| "github.com/spf13/viper" | |||
| "net/http" | |||
| "time" | |||
| ) | |||
| type LoginResponse struct { | |||
| Token *string `json:"token"` | |||
| } | |||
| func Login(w http.ResponseWriter, r *http.Request) { | |||
| var req AuthenticationRequest | |||
| err := json.NewDecoder(r.Body).Decode(&req) | |||
| if err != nil { | |||
| panic("Could not decode body") | |||
| } | |||
| var userData struct { | |||
| Id uint | |||
| Password string | |||
| Privileges uint | |||
| } | |||
| var resp LoginResponse | |||
| Db.Table("users").Select("id, password, privileges"). | |||
| Where("username = ?", req.Username).First(&userData) | |||
| var passwordMatches bool | |||
| passwordMatches, err = ComparePasswordAndHash(req.Password, userData.Password) | |||
| if err != nil { | |||
| panic("Could not compare password to hash") | |||
| } | |||
| if !passwordMatches { | |||
| resp.Token = nil | |||
| err = json.NewEncoder(w).Encode(resp) | |||
| return | |||
| } | |||
| token := jwt.NewWithClaims(jwt.SigningMethodHS256, &auth.Claims{ | |||
| Username: req.Username, | |||
| Privileges: userData.Privileges, | |||
| RegisteredClaims: jwt.RegisteredClaims{ | |||
| ExpiresAt: jwt.NewNumericDate(time.Now().Add(10 * time.Hour)), | |||
| }, | |||
| }) | |||
| secret := viper.GetString("app.secretKey") | |||
| tokenString, err := token.SignedString([]byte(secret)) | |||
| if err != nil { | |||
| panic("Could not generate JWT token") | |||
| } | |||
| resp.Token = &tokenString | |||
| err = json.NewEncoder(w).Encode(resp) | |||
| if err != nil { | |||
| panic("Could not deliver response") | |||
| } | |||
| } | |||
| @@ -0,0 +1,168 @@ | |||
| package endpoints | |||
| import ( | |||
| "crypto/rand" | |||
| "crypto/subtle" | |||
| "encoding/base64" | |||
| "encoding/json" | |||
| "errors" | |||
| "fmt" | |||
| "github.com/imosed/signet/auth" | |||
| . "github.com/imosed/signet/data" | |||
| "github.com/spf13/viper" | |||
| "golang.org/x/crypto/argon2" | |||
| "net/http" | |||
| "strings" | |||
| ) | |||
| const ( | |||
| SuperUser uint = iota | |||
| AdminPlus | |||
| Admin | |||
| ) | |||
| type Params struct { | |||
| Iterations uint32 | |||
| Memory uint32 | |||
| Parallelism uint8 | |||
| SaltLength uint32 | |||
| KeyLength uint32 | |||
| } | |||
| func GenerateRandomBytes(n uint32) ([]byte, error) { | |||
| var b = make([]byte, n) | |||
| _, err := rand.Read(b) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| return b, nil | |||
| } | |||
| func GenerateHash(password string, p *Params) (encodedHash string, err error) { | |||
| salt, err := GenerateRandomBytes(p.SaltLength) | |||
| if err != nil { | |||
| return "", err | |||
| } | |||
| var hash = argon2.IDKey([]byte(password), salt, p.Iterations, p.Memory, p.Parallelism, p.KeyLength) | |||
| var bSalt = base64.RawStdEncoding.EncodeToString(salt) | |||
| var bHash = base64.RawStdEncoding.EncodeToString(hash) | |||
| encodedHash = fmt.Sprintf("$argon2id$v=%d$m=%d,t=%d,p=%d$%s$%s", argon2.Version, p.Memory, p.Iterations, p.Parallelism, bSalt, bHash) | |||
| return encodedHash, nil | |||
| } | |||
| func ComparePasswordAndHash(password, encodedHash string) (match bool, err error) { | |||
| p, salt, hash, err := DecodeHash(encodedHash) | |||
| if err != nil { | |||
| return false, err | |||
| } | |||
| var otherHash = argon2.IDKey([]byte(password), salt, p.Iterations, p.Memory, p.Parallelism, p.KeyLength) | |||
| if subtle.ConstantTimeCompare(hash, otherHash) == 1 { | |||
| return true, nil | |||
| } | |||
| return false, nil | |||
| } | |||
| func DecodeHash(encodedHash string) (p *Params, salt, hash []byte, err error) { | |||
| var details = strings.Split(encodedHash, "$") | |||
| if len(details) != 6 { | |||
| return nil, nil, nil, errors.New("the encoded hash is not in the correct format") | |||
| } | |||
| var version int | |||
| _, err = fmt.Sscanf(details[2], "v=%d", &version) | |||
| if err != nil { | |||
| return nil, nil, nil, err | |||
| } | |||
| if version != argon2.Version { | |||
| return nil, nil, nil, errors.New("the version of argon2 does not match the hash string") | |||
| } | |||
| p = &Params{} | |||
| _, err = fmt.Sscanf(details[3], "m=%d,t=%d,p=%d", &p.Memory, &p.Iterations, &p.Parallelism) | |||
| if err != nil { | |||
| return nil, nil, nil, err | |||
| } | |||
| salt, err = base64.RawStdEncoding.DecodeString(details[4]) | |||
| if err != nil { | |||
| return nil, nil, nil, err | |||
| } | |||
| p.SaltLength = uint32(len(salt)) | |||
| hash, err = base64.RawStdEncoding.DecodeString(details[5]) | |||
| if err != nil { | |||
| return nil, nil, nil, err | |||
| } | |||
| p.KeyLength = uint32(len(hash)) | |||
| return p, salt, hash, nil | |||
| } | |||
| type AuthenticationRequest struct { | |||
| Username string `json:"username"` | |||
| Password string `json:"password"` | |||
| } | |||
| func noUsersRegistered() bool { | |||
| results := Db.Find(&User{}) | |||
| return results.RowsAffected == 0 | |||
| } | |||
| func determinePrivileges() uint { | |||
| if noUsersRegistered() { | |||
| return SuperUser | |||
| } else { | |||
| return Admin | |||
| } | |||
| } | |||
| func Register(w http.ResponseWriter, r *http.Request) { | |||
| var req AuthenticationRequest | |||
| err := json.NewDecoder(r.Body).Decode(&req) | |||
| if err != nil { | |||
| panic("Could not decode body") | |||
| } | |||
| var claims *auth.Claims | |||
| claims, err = auth.GetUserClaims(r) | |||
| if err != nil { | |||
| panic("Could not determine if user is authenticated") | |||
| } | |||
| if claims.Privileges <= AdminPlus || noUsersRegistered() { | |||
| hash, err := GenerateHash(req.Password, &Params{ | |||
| Memory: uint32(viper.GetInt("hashing.memory")), | |||
| Iterations: uint32(viper.GetInt("hashing.iterations")), | |||
| Parallelism: uint8(viper.GetInt("hashing.parallelism")), | |||
| SaltLength: uint32(viper.GetInt("hashing.saltLength")), | |||
| KeyLength: uint32(viper.GetInt("hashing.keyLength")), | |||
| }) | |||
| if err != nil { | |||
| panic("Could not generate hash for registration") | |||
| } | |||
| Db.Create(&User{ | |||
| Username: req.Username, | |||
| Password: hash, | |||
| Privileges: determinePrivileges(), | |||
| }) | |||
| err = json.NewEncoder(w).Encode(SuccessResponse{Success: true}) | |||
| if err != nil { | |||
| panic("Could not deliver successful account creation response") | |||
| } | |||
| } else if !noUsersRegistered() { | |||
| err = json.NewEncoder(w).Encode(SuccessResponse{Success: false}) | |||
| if err != nil { | |||
| panic("Could not deliver unsuccessful account creation response") | |||
| } | |||
| } else if claims.Privileges > SuperUser { | |||
| w.WriteHeader(403) | |||
| } | |||
| } | |||
| @@ -0,0 +1,91 @@ | |||
| package endpoints | |||
| import ( | |||
| "encoding/json" | |||
| "fmt" | |||
| . "github.com/imosed/signet/data" | |||
| "github.com/stellar/go/clients/horizonclient" | |||
| "github.com/stellar/go/protocols/horizon" | |||
| "net/http" | |||
| ) | |||
| var client = horizonclient.DefaultTestNetClient | |||
| type SubmitFundRequest struct { | |||
| FundId uint `json:"fundId"` | |||
| } | |||
| func SubmitFund(w http.ResponseWriter, r *http.Request) { | |||
| var req SubmitFundRequest | |||
| err := json.NewDecoder(r.Body).Decode(&req) | |||
| if err != nil { | |||
| panic("Could not decode body") | |||
| } | |||
| var fund RewardFund | |||
| Db.Find(&fund, req.FundId) | |||
| //source := keypair.MustParseFull(fund.FundWallet) | |||
| //sourceReq := horizonclient.AccountRequest{AccountID: source.Address()} | |||
| //var sourceAcct horizon.Account | |||
| //sourceAcct, err = client.AccountDetail(sourceReq) | |||
| offerReq := horizonclient.OfferRequest{ | |||
| Selling: fmt.Sprintf("%s:%s", fund.Asset, fund.IssuerWallet), | |||
| Seller: fund.IssuerWallet, | |||
| Cursor: "0", | |||
| } | |||
| var offers horizon.OffersPage | |||
| offers, err = client.Offers(offerReq) | |||
| for _, o := range offers.Embedded.Records { | |||
| if float64(o.PriceR.N)/float64(o.PriceR.D) == fund.Price { | |||
| fmt.Println(o.PriceR.N) | |||
| fmt.Println(o.Amount) | |||
| } | |||
| } | |||
| //var tx *txnbuild.Transaction | |||
| //tx, err = txnbuild.NewTransaction( | |||
| // txnbuild.TransactionParams{ | |||
| // SourceAccount: &sourceAcct, | |||
| // IncrementSequenceNum: true, | |||
| // Operations: []txnbuild.Operation{ | |||
| // &txnbuild.ManageBuyOffer{ | |||
| // Selling: txnbuild.NativeAsset{}, | |||
| // Buying: txnbuild.CreditAsset{ | |||
| // Code: fund.Asset, | |||
| // Issuer: fund.IssuerWallet, | |||
| // }, | |||
| // Amount: fmt.Sprintf("%f", SumContributions(fund.Contributions)), | |||
| // Price: xdr.Price{}, // TODO: get price | |||
| // OfferID: 0, | |||
| // SourceAccount: "", | |||
| // }, | |||
| // }, | |||
| // BaseFee: txnbuild.MinBaseFee, | |||
| // Memo: txnbuild.Memo(txnbuild.MemoText(strconv.Itoa(int(fund.Model.ID)))), | |||
| // Preconditions: txnbuild.Preconditions{ | |||
| // TimeBounds: txnbuild.NewInfiniteTimeout(), // TODO: change from infinite | |||
| // }, | |||
| // }) | |||
| //if err != nil { | |||
| // panic("Could not submit reward fund") | |||
| //} | |||
| // | |||
| //tx, err = tx.Sign(network.TestNetworkPassphrase, source) | |||
| //if err != nil { | |||
| // panic("Could not submit fund") | |||
| //} | |||
| // | |||
| //var response horizon.Transaction | |||
| //response, err = client.SubmitTransaction(tx) | |||
| var resp SuccessResponse | |||
| //resp.Success = response.Successful | |||
| err = json.NewEncoder(w).Encode(resp) | |||
| if err != nil { | |||
| panic("Could not deliver response") | |||
| } | |||
| } | |||
| @@ -0,0 +1,60 @@ | |||
| module github.com/imosed/signet | |||
| go 1.19 | |||
| require ( | |||
| github.com/golang-jwt/jwt/v4 v4.4.3 | |||
| github.com/gorilla/mux v1.8.0 | |||
| github.com/gorilla/websocket v1.5.0 | |||
| github.com/pdrum/swagger-automation v0.0.0-20190629163613-c8c7c80ba858 | |||
| github.com/spf13/viper v0.0.0-20150621231900-db7ff930a189 | |||
| github.com/stellar/go v0.0.0-20221028081946-9308f9531041 | |||
| golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa | |||
| golang.org/x/net v0.0.0-20220225172249-27dd8689420f | |||
| gorm.io/driver/postgres v1.4.5 | |||
| gorm.io/gorm v1.24.1 | |||
| ) | |||
| require ( | |||
| github.com/BurntSushi/toml v0.3.1 // indirect | |||
| github.com/davecgh/go-spew v1.1.1 // indirect | |||
| github.com/go-chi/chi v4.0.3+incompatible // indirect | |||
| github.com/go-errors/errors v0.0.0-20150906023321-a41850380601 // indirect | |||
| github.com/gorilla/schema v1.1.0 // indirect | |||
| github.com/jackc/chunkreader/v2 v2.0.1 // indirect | |||
| github.com/jackc/pgconn v1.13.0 // indirect | |||
| github.com/jackc/pgio v1.0.0 // indirect | |||
| github.com/jackc/pgpassfile v1.0.0 // indirect | |||
| github.com/jackc/pgproto3/v2 v2.3.1 // indirect | |||
| github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect | |||
| github.com/jackc/pgtype v1.12.0 // indirect | |||
| github.com/jackc/pgx/v4 v4.17.2 // indirect | |||
| github.com/jinzhu/inflection v1.0.0 // indirect | |||
| github.com/jinzhu/now v1.1.4 // indirect | |||
| github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect | |||
| github.com/kr/pretty v0.1.0 // indirect | |||
| github.com/kr/text v0.1.0 // indirect | |||
| github.com/labstack/echo v3.3.10+incompatible // indirect | |||
| github.com/labstack/gommon v0.2.9 // indirect | |||
| github.com/magiconair/properties v1.5.4 // indirect | |||
| github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739 // indirect | |||
| github.com/mattn/go-colorable v0.1.6 // indirect | |||
| github.com/mattn/go-isatty v0.0.12 // indirect | |||
| github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366 // indirect | |||
| github.com/pkg/errors v0.9.1 // indirect | |||
| github.com/pmezard/go-difflib v1.0.0 // indirect | |||
| github.com/segmentio/go-loggly v0.5.1-0.20171222203950-eb91657e62b2 // indirect | |||
| github.com/sirupsen/logrus v1.4.2 // indirect | |||
| github.com/spf13/cast v0.0.0-20150508191742-4d07383ffe94 // indirect | |||
| github.com/spf13/jwalterweatherman v0.0.0-20141219030609-3d60171a6431 // indirect | |||
| github.com/spf13/pflag v0.0.0-20161005214240-4bd69631f475 // indirect | |||
| github.com/stellar/go-xdr v0.0.0-20211103144802-8017fc4bdfee // indirect | |||
| github.com/stretchr/objx v0.4.0 // indirect | |||
| github.com/stretchr/testify v1.8.0 // indirect | |||
| github.com/valyala/bytebufferpool v1.0.0 // indirect | |||
| github.com/valyala/fasttemplate v1.0.1 // indirect | |||
| golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect | |||
| golang.org/x/text v0.3.7 // indirect | |||
| gopkg.in/yaml.v2 v2.2.8 // indirect | |||
| gopkg.in/yaml.v3 v3.0.1 // indirect | |||
| ) | |||
| @@ -0,0 +1,281 @@ | |||
| github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= | |||
| github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | |||
| github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= | |||
| github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= | |||
| github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f h1:zvClvFQwU++UpIUBGC8YmDlfhUrweEy1R1Fj1gu5iIM= | |||
| github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= | |||
| github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= | |||
| github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= | |||
| github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= | |||
| github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= | |||
| github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= | |||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | |||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | |||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | |||
| github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= | |||
| github.com/fatih/structs v1.0.0 h1:BrX964Rv5uQ3wwS+KRUAJCBBw5PQmgJfJ6v4yly5QwU= | |||
| github.com/gavv/monotime v0.0.0-20161010190848-47d58efa6955 h1:gmtGRvSexPU4B1T/yYo0sLOKzER1YT+b4kPxPpm0Ty4= | |||
| github.com/go-chi/chi v4.0.3+incompatible h1:gakN3pDJnzZN5jqFV2TEdF66rTfKeITyR8qu6ekICEY= | |||
| github.com/go-chi/chi v4.0.3+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= | |||
| github.com/go-errors/errors v0.0.0-20150906023321-a41850380601 h1:jxTbmDuqQUTI6MscgbqB39vtxGfr2fi61nYIcFQUnlE= | |||
| github.com/go-errors/errors v0.0.0-20150906023321-a41850380601/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= | |||
| github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= | |||
| github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= | |||
| github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= | |||
| github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= | |||
| github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= | |||
| github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU= | |||
| github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= | |||
| github.com/google/go-querystring v0.0.0-20160401233042-9235644dd9e5 h1:oERTZ1buOUYlpmKaqlO5fYmz8cZ1rYu5DieJzF4ZVmU= | |||
| github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= | |||
| github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= | |||
| github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= | |||
| github.com/gorilla/schema v1.1.0 h1:CamqUDOFUBqzrvxuz2vEwo8+SUdwsluFh7IlzJh30LY= | |||
| github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= | |||
| github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= | |||
| github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= | |||
| github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= | |||
| github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk= | |||
| github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= | |||
| github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= | |||
| github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= | |||
| github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= | |||
| github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= | |||
| github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= | |||
| github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= | |||
| github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= | |||
| github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= | |||
| github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= | |||
| github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= | |||
| github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= | |||
| github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= | |||
| github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= | |||
| github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= | |||
| github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= | |||
| github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= | |||
| github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= | |||
| github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= | |||
| github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= | |||
| github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= | |||
| github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= | |||
| github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= | |||
| github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= | |||
| github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= | |||
| github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= | |||
| github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= | |||
| github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y= | |||
| github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= | |||
| github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= | |||
| github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= | |||
| github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= | |||
| github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= | |||
| github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= | |||
| github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= | |||
| github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w= | |||
| github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= | |||
| github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= | |||
| github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= | |||
| github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= | |||
| github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= | |||
| github.com/jackc/pgx/v4 v4.17.2 h1:0Ut0rpeKwvIVbMQ1KbMBU4h6wxehBI535LK6Flheh8E= | |||
| github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw= | |||
| github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= | |||
| github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= | |||
| github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= | |||
| github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= | |||
| github.com/jarcoal/httpmock v0.0.0-20161210151336-4442edb3db31 h1:Aw95BEvxJ3K6o9GGv5ppCd1P8hkeIeEJ30FO+OhOJpM= | |||
| github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= | |||
| github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= | |||
| github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas= | |||
| github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= | |||
| github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | |||
| github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U= | |||
| github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | |||
| github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= | |||
| github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | |||
| github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= | |||
| github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= | |||
| github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | |||
| github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= | |||
| github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= | |||
| github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | |||
| github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= | |||
| github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= | |||
| github.com/labstack/gommon v0.2.9 h1:heVeuAYtevIQVYkGj6A41dtfT91LrvFG220lavpWhrU= | |||
| github.com/labstack/gommon v0.2.9/go.mod h1:E8ZTmW9vw5az5/ZyHWCp0Lw4OH2ecsaBP1C/NKavGG4= | |||
| github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= | |||
| github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= | |||
| github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= | |||
| github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= | |||
| github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= | |||
| github.com/magiconair/properties v1.5.4 h1:5Y3GEEL4cWijFkb6jtcVs3lX2EWA1ZKq64qu9cd8W7s= | |||
| github.com/magiconair/properties v1.5.4/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= | |||
| github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739 h1:ykXz+pRRTibcSjG1yRhpdSHInF8yZY/mfn+Rz2Nd1rE= | |||
| github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739/go.mod h1:zUx1mhth20V3VKgL5jbd1BSQcW4Fy6Qs4PZvQwRFwzM= | |||
| github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= | |||
| github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= | |||
| github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= | |||
| github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= | |||
| github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= | |||
| github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= | |||
| github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= | |||
| github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= | |||
| github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= | |||
| github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366 h1:1ypTpKUfEOyX1YsJru6lLq7hrmK+QGECpJQ1PHUHuGo= | |||
| github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= | |||
| github.com/moul/http2curl v0.0.0-20161031194548-4e24498b31db h1:eZgFHVkk9uOTaOQLC6tgjkzdp7Ays8eEVecBcfHZlJQ= | |||
| github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= | |||
| github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= | |||
| github.com/pdrum/swagger-automation v0.0.0-20190629163613-c8c7c80ba858 h1:lgbJiJQx8bXo+eM88AFdd0VxUvaTLzCBXpK+H9poJ+Y= | |||
| github.com/pdrum/swagger-automation v0.0.0-20190629163613-c8c7c80ba858/go.mod h1:y02HeaN0visd95W6cEX2NXDv5sCwyqfzucWTdDGEwYY= | |||
| github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | |||
| github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | |||
| github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | |||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | |||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | |||
| github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= | |||
| github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= | |||
| github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= | |||
| github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= | |||
| github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= | |||
| github.com/segmentio/go-loggly v0.5.1-0.20171222203950-eb91657e62b2 h1:S4OC0+OBKz6mJnzuHioeEat74PuQ4Sgvbf8eus695sc= | |||
| github.com/segmentio/go-loggly v0.5.1-0.20171222203950-eb91657e62b2/go.mod h1:8zLRYR5npGjaOXgPSKat5+oOh+UHd8OdbS18iqX9F6Y= | |||
| github.com/sergi/go-diff v0.0.0-20161205080420-83532ca1c1ca h1:oR/RycYTFTVXzND5r4FdsvbnBn0HJXSVeNAnwaTXRwk= | |||
| github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= | |||
| github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= | |||
| github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= | |||
| github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= | |||
| github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= | |||
| github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= | |||
| github.com/spf13/cast v0.0.0-20150508191742-4d07383ffe94 h1:JmfC365KywYwHB946TTiQWEb8kqPY+pybPLoGE9GgVk= | |||
| github.com/spf13/cast v0.0.0-20150508191742-4d07383ffe94/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg= | |||
| github.com/spf13/jwalterweatherman v0.0.0-20141219030609-3d60171a6431 h1:XTHrT015sxHyJ5FnQ0AeemSspZWaDq7DoTRW0EVsDCE= | |||
| github.com/spf13/jwalterweatherman v0.0.0-20141219030609-3d60171a6431/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= | |||
| github.com/spf13/pflag v0.0.0-20161005214240-4bd69631f475 h1:RtZIgreTwcayPTOw7G5jqNSaRISGXa9CwlUl+hSyMtg= | |||
| github.com/spf13/pflag v0.0.0-20161005214240-4bd69631f475/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= | |||
| github.com/spf13/viper v0.0.0-20150621231900-db7ff930a189 h1:fvB1AFbBd6SfI9Rd0ooAJp8uLkZDbZaLFHi7ZnNP6uI= | |||
| github.com/spf13/viper v0.0.0-20150621231900-db7ff930a189/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= | |||
| github.com/stellar/go v0.0.0-20221028081946-9308f9531041 h1:o5bk0+e1isqY4yLIzEHR3FEBQYdGMf0iDe+rEjYD1YE= | |||
| github.com/stellar/go v0.0.0-20221028081946-9308f9531041/go.mod h1:AbsNBrmclUvQcs0EeN+LDhubhX7tyo18r5fw0SCz/oM= | |||
| github.com/stellar/go-xdr v0.0.0-20211103144802-8017fc4bdfee h1:fbVs0xmXpBvVS4GBeiRmAE3Le70ofAqFMch1GTiq/e8= | |||
| github.com/stellar/go-xdr v0.0.0-20211103144802-8017fc4bdfee/go.mod h1:yoxyU/M8nl9LKeWIoBrbDPQ7Cy+4jxRcWcOayZ4BMps= | |||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | |||
| github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | |||
| github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= | |||
| github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= | |||
| github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | |||
| github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | |||
| github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | |||
| github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | |||
| github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | |||
| github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | |||
| github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | |||
| github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= | |||
| github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | |||
| github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= | |||
| github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= | |||
| github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4= | |||
| github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8= | |||
| github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= | |||
| github.com/xdrpp/goxdr v0.1.1 h1:E1B2c6E8eYhOVyd7yEpOyopzTPirUeF6mVOfXfGyJyc= | |||
| github.com/xeipuuv/gojsonpointer v0.0.0-20151027082146-e0fe6f683076 h1:KM4T3G70MiR+JtqplcYkNVoNz7pDwYaBxWBXQK804So= | |||
| github.com/xeipuuv/gojsonreference v0.0.0-20150808065054-e02fc20de94c h1:XZWnr3bsDQWAZg4Ne+cPoXRPILrNlPNQfxBuwLl43is= | |||
| github.com/xeipuuv/gojsonschema v0.0.0-20161231055540-f06f290571ce h1:cVSRGH8cOveJNwFEEZLXtB+XMnRqKLjUP6V/ZFYQCXI= | |||
| github.com/yalp/jsonpath v0.0.0-20150812003900-31a79c7593bb h1:06WAhQa+mYv7BiOk13B/ywyTlkoE/S7uu6TBKU6FHnE= | |||
| github.com/yudai/gojsondiff v0.0.0-20170107030110-7b1b7adf999d h1:yJIizrfO599ot2kQ6Af1enICnwBD3XoxgX3MrMwot2M= | |||
| github.com/yudai/golcs v0.0.0-20150405163532-d1c525dea8ce h1:888GrqRxabUce7lj4OaoShPxodm3kXOMpSa85wdYzfY= | |||
| github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= | |||
| go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= | |||
| go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= | |||
| go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= | |||
| go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= | |||
| go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= | |||
| go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= | |||
| go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= | |||
| go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= | |||
| go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= | |||
| go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= | |||
| go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= | |||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | |||
| golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= | |||
| golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | |||
| golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | |||
| golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | |||
| golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | |||
| golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | |||
| golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= | |||
| golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | |||
| golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | |||
| golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= | |||
| golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= | |||
| golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= | |||
| golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= | |||
| golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= | |||
| golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= | |||
| golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | |||
| golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | |||
| golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | |||
| golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | |||
| golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= | |||
| golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | |||
| golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= | |||
| golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= | |||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | |||
| golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | |||
| golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | |||
| golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | |||
| golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
| golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
| golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
| golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
| golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
| golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
| golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
| golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
| golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
| golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
| golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |||
| golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs= | |||
| golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |||
| golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= | |||
| golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | |||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | |||
| golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= | |||
| golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | |||
| golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | |||
| golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | |||
| golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= | |||
| golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | |||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | |||
| golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= | |||
| golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= | |||
| golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= | |||
| golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | |||
| golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | |||
| golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | |||
| golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= | |||
| golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
| golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
| golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
| golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
| golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | |||
| gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= | |||
| gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | |||
| gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= | |||
| gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= | |||
| gopkg.in/gavv/httpexpect.v1 v1.0.0-20170111145843-40724cf1e4a0 h1:r5ptJ1tBxVAeqw4CrYWhXIMr0SybY3CDHuIbCg5CFVw= | |||
| gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= | |||
| gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= | |||
| gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | |||
| gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= | |||
| gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | |||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | |||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | |||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | |||
| gorm.io/driver/postgres v1.4.5 h1:mTeXTTtHAgnS9PgmhN2YeUbazYpLhUI1doLnw42XUZc= | |||
| gorm.io/driver/postgres v1.4.5/go.mod h1:GKNQYSJ14qvWkvPwXljMGehpKrhlDNsqYRr5HnYGncg= | |||
| gorm.io/gorm v1.24.1-0.20221019064659-5dd2bb482755/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= | |||
| gorm.io/gorm v1.24.1 h1:CgvzRniUdG67hBAzsxDGOAuq4Te1osVMYsa1eQbd4fs= | |||
| gorm.io/gorm v1.24.1/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= | |||
| honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= | |||
| @@ -0,0 +1,11 @@ | |||
| package main | |||
| import "github.com/imosed/signet/data" | |||
| func SumContributions(contributions []data.Contribution) (sum float64) { | |||
| total := 0.0 | |||
| for _, contribution := range contributions { | |||
| total += contribution.Amount | |||
| } | |||
| return total | |||
| } | |||
| @@ -0,0 +1,49 @@ | |||
| package main | |||
| import ( | |||
| "fmt" | |||
| "github.com/gorilla/mux" | |||
| "github.com/imosed/signet/data" | |||
| "github.com/imosed/signet/endpoints" | |||
| "github.com/spf13/viper" | |||
| "net/http" | |||
| ) | |||
| var err error | |||
| // Testnet wallet: GDQZ34LBZSUYFR3DSDYFDLNYDHRXPUB76FIW2FTESYHRUOGZ6GXN5LOS | |||
| // Testnet secret: SCDYZYNZIDYHU3HNIBDZEVCRD2QB2VOZWJR3XP63FA6AOC6GQQSZ3C3U | |||
| // TODO: beignet.io | |||
| func main() { | |||
| viper.SetConfigFile("config.production.json") // TODO: change this for deployment | |||
| err = viper.ReadInConfig() | |||
| if err != nil { | |||
| panic("Could not read in Viper config") | |||
| } | |||
| data.InitializeDatabase() | |||
| go endpoints.InitializeContributionStream() | |||
| router := mux.NewRouter() | |||
| router.HandleFunc("/GetRewardFunds", endpoints.GetRewardFunds) | |||
| router.HandleFunc("/GetRewardFund", endpoints.GetRewardFund) | |||
| router.HandleFunc("/GetContributions", endpoints.GetContributions) | |||
| router.HandleFunc("/CreateRewardFund", endpoints.CreateRewardFund) | |||
| router.HandleFunc("/CloseRewardFund", endpoints.CloseRewardFund) | |||
| router.HandleFunc("/SubmitFund", endpoints.SubmitFund) | |||
| router.HandleFunc("/Contribute", endpoints.Contribute) | |||
| router.HandleFunc("/ContributorStream", endpoints.ContributorStream) | |||
| router.HandleFunc("/Login", endpoints.Login) | |||
| router.HandleFunc("/Register", endpoints.Register) | |||
| router.HandleFunc("/EscalatePrivileges", endpoints.EscalatePrivileges) | |||
| port := viper.GetInt("app.port") | |||
| fmt.Printf("Running on port %d...\n", port) | |||
| err = http.ListenAndServe(fmt.Sprintf(":%d", port), router) | |||
| if err != nil { | |||
| panic(fmt.Sprintf("Could not bind to port %d", port)) | |||
| } | |||
| } | |||