Skip to content

Commit

Permalink
server/dex: use the real bond parser
Browse files Browse the repository at this point in the history
  • Loading branch information
chappjc committed Sep 16, 2022
1 parent 2084b86 commit 9610fb5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions server/dex/dex.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package dex
import (
"context"
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
Expand All @@ -19,6 +20,7 @@ import (
"decred.org/dcrdex/server/account"
"decred.org/dcrdex/server/apidata"
"decred.org/dcrdex/server/asset"
"decred.org/dcrdex/server/asset/dcr"
"decred.org/dcrdex/server/auth"
"decred.org/dcrdex/server/coinlock"
"decred.org/dcrdex/server/comms"
Expand Down Expand Up @@ -602,9 +604,17 @@ func NewDEX(ctx context.Context, cfg *DexConf) (*DEX, error) {
return fc.FeeCoin(coinID)
}

dummyBondParser := func(assetID uint32, ver uint16, rawTx, bondScript []byte) (bondCoinID []byte, amt int64, bondAddr string,
lockTime int64, acct account.AccountID, err error) {
return // actual parser will wrap server/asset/dcr.ParseBondTx
bondTxParser := func(assetID uint32, version uint16, rawTx, bondData []byte) (bondCoinID []byte, amt int64,
bondAddr string, lockTime int64, acct account.AccountID, err error) {
if assetID != dcr.BipID {
err = errors.New("asset not supported")
return
}
// TODO: If the parser remains a package-level function, consider a
// driver method. If the parser becomes a backend method, get it from
// the backedAssets map containing the asset.Backend instances.
bondCoinID, amt, bondAddr, _, lockTime, acct, err = dcr.ParseBondTx(version, rawTx)
return
}

authCfg := auth.Config{
Expand All @@ -615,7 +625,7 @@ func NewDEX(ctx context.Context, cfg *DexConf) (*DEX, error) {
FeeChecker: feeChecker,
BondConfs: 1, // TODO
BondIncrement: cfg.BondIncrement,
BondTxParser: dummyBondParser, // NOTE: backend instantiation sets the package-level network params
BondTxParser: bondTxParser,
BondExpiry: uint64(bondExpiry),
UserUnbooker: userUnbookFun,
MiaUserTimeout: cfg.BroadcastTimeout,
Expand Down

0 comments on commit 9610fb5

Please sign in to comment.