Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit eb3c884

Browse files
authored
Merge pull request #2069 from OpenBazaar/brian.supereconomy
[NO MERGE] Add Super Economic to Server
2 parents 0dd0c81 + 5c0e3af commit eb3c884

File tree

15 files changed

+132
-102
lines changed

15 files changed

+132
-102
lines changed

api/jsonapi.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3473,6 +3473,8 @@ func (i *jsonAPIHandler) GETEstimateFee(w http.ResponseWriter, r *http.Request)
34733473
feeLevel = wallet.NORMAL
34743474
case "ECONOMIC":
34753475
feeLevel = wallet.ECONOMIC
3476+
case "SUPER_ECONOMIC":
3477+
feeLevel = wallet.SUPER_ECONOMIC
34763478
default:
34773479
ErrorResponse(w, http.StatusBadRequest, "Unknown feeLevel")
34783480
return
@@ -3516,25 +3518,28 @@ func (i *jsonAPIHandler) GETEstimateFee(w http.ResponseWriter, r *http.Request)
35163518
func (i *jsonAPIHandler) GETFees(w http.ResponseWriter, r *http.Request) {
35173519
_, coinType := path.Split(r.URL.Path)
35183520
type fees struct {
3519-
Priority *repo.CurrencyValue `json:"priority"`
3520-
Normal *repo.CurrencyValue `json:"normal"`
3521-
Economic *repo.CurrencyValue `json:"economic"`
3521+
Priority *repo.CurrencyValue `json:"priority"`
3522+
Normal *repo.CurrencyValue `json:"normal"`
3523+
Economic *repo.CurrencyValue `json:"economic"`
3524+
SuperEconomic *repo.CurrencyValue `json:"superEconomic"`
35223525
}
35233526
if coinType == "fees" {
35243527
ret := make(map[string]interface{})
35253528
for ct, wal := range i.node.Multiwallet {
35263529
priority := wal.GetFeePerByte(wallet.PRIOIRTY)
35273530
normal := wal.GetFeePerByte(wallet.NORMAL)
35283531
economic := wal.GetFeePerByte(wallet.ECONOMIC)
3532+
superEconomic := wal.GetFeePerByte(wallet.SUPER_ECONOMIC)
35293533
defn, err := i.node.LookupCurrency(wal.CurrencyCode())
35303534
if err != nil {
35313535
ErrorResponse(w, http.StatusInternalServerError, err.Error())
35323536
return
35333537
}
35343538
ret[ct.CurrencyCode()] = fees{
3535-
Priority: &repo.CurrencyValue{Currency: defn, Amount: &priority},
3536-
Normal: &repo.CurrencyValue{Currency: defn, Amount: &normal},
3537-
Economic: &repo.CurrencyValue{Currency: defn, Amount: &economic},
3539+
Priority: &repo.CurrencyValue{Currency: defn, Amount: &priority},
3540+
Normal: &repo.CurrencyValue{Currency: defn, Amount: &normal},
3541+
Economic: &repo.CurrencyValue{Currency: defn, Amount: &economic},
3542+
SuperEconomic: &repo.CurrencyValue{Currency: defn, Amount: &superEconomic},
35383543
}
35393544
}
35403545
out, err := json.MarshalIndent(ret, "", " ")
@@ -3553,15 +3558,17 @@ func (i *jsonAPIHandler) GETFees(w http.ResponseWriter, r *http.Request) {
35533558
priority := wal.GetFeePerByte(wallet.PRIOIRTY)
35543559
normal := wal.GetFeePerByte(wallet.NORMAL)
35553560
economic := wal.GetFeePerByte(wallet.ECONOMIC)
3561+
superEconomic := wal.GetFeePerByte(wallet.SUPER_ECONOMIC)
35563562
defn, err := i.node.LookupCurrency(wal.CurrencyCode())
35573563
if err != nil {
35583564
ErrorResponse(w, http.StatusInternalServerError, err.Error())
35593565
return
35603566
}
35613567
f := fees{
3562-
Priority: &repo.CurrencyValue{Currency: defn, Amount: &priority},
3563-
Normal: &repo.CurrencyValue{Currency: defn, Amount: &normal},
3564-
Economic: &repo.CurrencyValue{Currency: defn, Amount: &economic},
3568+
Priority: &repo.CurrencyValue{Currency: defn, Amount: &priority},
3569+
Normal: &repo.CurrencyValue{Currency: defn, Amount: &normal},
3570+
Economic: &repo.CurrencyValue{Currency: defn, Amount: &economic},
3571+
SuperEconomic: &repo.CurrencyValue{Currency: defn, Amount: &superEconomic},
35653572
}
35663573
out, err := json.MarshalIndent(f, "", " ")
35673574
if err != nil {

core/order.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func processOfflineDirectOrder(n *OpenBazaarNode, wal wallet.Wallet, contract *p
390390
if !ok {
391391
return "", "", *big.NewInt(0), errors.New("invalid payment amount")
392392
}
393-
fpb := wal.GetFeePerByte(wallet.NORMAL)
393+
fpb := wal.GetFeePerByte(wallet.SUPER_ECONOMIC)
394394
f := new(big.Int).Mul(&fpb, big.NewInt(int64(EscrowReleaseSize)))
395395
t := new(big.Int).Div(total, big.NewInt(4))
396396

core/spend.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ func (n *OpenBazaarNode) Spend(args *SpendRequest) (*SpendResponse, error) {
9797
feeLevel = wallet.NORMAL
9898
case "ECONOMIC":
9999
feeLevel = wallet.ECONOMIC
100+
case "SUPER_ECONOMIC":
101+
feeLevel = wallet.SUPER_ECONOMIC
100102
default:
101103
feeLevel = wallet.NORMAL
102104
}

schema/configuration.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,17 @@ type WalletsConfig struct {
3939
}
4040

4141
type CoinConfig struct {
42-
Type string `json:"Type"`
43-
APIPool []string `json:"API"`
44-
APITestnetPool []string `json:"APITestnet"`
45-
MaxFee uint64 `json:"MaxFee"`
46-
FeeAPI string `json:"FeeAPI"`
47-
HighFeeDefault uint64 `json:"HighFeeDefault"`
48-
MediumFeeDefault uint64 `json:"MediumFeeDefault"`
49-
LowFeeDefault uint64 `json:"LowFeeDefault"`
50-
TrustedPeer string `json:"TrustedPeer"`
51-
WalletOptions map[string]interface{} `json:"WalletOptions"`
42+
Type string `json:"Type"`
43+
APIPool []string `json:"API"`
44+
APITestnetPool []string `json:"APITestnet"`
45+
MaxFee uint64 `json:"MaxFee"`
46+
FeeAPI string `json:"FeeAPI"`
47+
SuperLowFeeDefault uint64 `json:"SuperLowFeeDefault"`
48+
HighFeeDefault uint64 `json:"HighFeeDefault"`
49+
MediumFeeDefault uint64 `json:"MediumFeeDefault"`
50+
LowFeeDefault uint64 `json:"LowFeeDefault"`
51+
TrustedPeer string `json:"TrustedPeer"`
52+
WalletOptions map[string]interface{} `json:"WalletOptions"`
5253
}
5354

5455
type DataSharing struct {

vendor/github.com/OpenBazaar/multiwallet/bitcoin/wallet.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/OpenBazaar/multiwallet/bitcoincash/wallet.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/OpenBazaar/multiwallet/config/config.go

Lines changed: 49 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/OpenBazaar/multiwallet/litecoin/wallet.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/OpenBazaar/multiwallet/util/fees.go

Lines changed: 14 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/OpenBazaar/multiwallet/zcash/wallet.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)