Skip to content

Commit

Permalink
Set the default privacy policy
Browse files Browse the repository at this point in the history
Update the workflow cache version
  • Loading branch information
dmigwi committed Aug 21, 2023
1 parent 860029e commit b980746
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
id: cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-v2
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-v3
restore-keys: |
${{ runner.os }}-go-
Expand Down
6 changes: 6 additions & 0 deletions libwallet/assets/dcr/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ func (asset *Asset) PurchaseTickets(account, numTickets int32, vspHost, passphra
}
defer asset.LockWallet()

log.Info("Setting the ticket(s) purchasing account info")
vspClient.SetAccountInfo(account, account)

request := &w.PurchaseTicketsRequest{
Count: int(numTickets),
SourceAccount: uint32(account),
Expand Down Expand Up @@ -454,6 +457,9 @@ func (asset *Asset) buyTicket(ctx context.Context, passphrase string, sdiff dcru
return err
}

log.Info("Setting the ticket(s) purchasing account info")
cfg.VspClient.SetAccountInfo(cfg.PurchaseAccount, cfg.PurchaseAccount)

// Count is 1 to prevent combining multiple split outputs in one tx,
// which can be used to link the tickets eventually purchased with the
// split outputs.
Expand Down
4 changes: 4 additions & 0 deletions libwallet/assets/dcr/vsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func (asset *Asset) VSPClient(host string, pubKey []byte) (*vsp.Client, error) {
PubKey: pubKey,
Dialer: nil, // optional, but consider providing a value
Wallet: asset.Internal().DCR,
Params: asset.chainParams,
Policy: &vsp.Policy{
MaxFee: 0.1e8,
},
}
client, err := vsp.New(cfg)
if err != nil {
Expand Down
18 changes: 16 additions & 2 deletions libwallet/internal/vsp/vsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,20 @@ func New(cfg Config) (*Client, error) {
return nil, err
}

if len(cfg.PubKey) == 0 {
return nil, errors.New("pubkey option not set")
}

if cfg.Wallet == nil {
return nil, fmt.Errorf("wallet option not set")
return nil, errors.New("wallet option not set")
}

if cfg.Params == nil {
return nil, fmt.Errorf("params option not set")
return nil, errors.New("params option not set")
}

if cfg.Policy == nil {
return nil, errors.New("policy option not set")
}

client := &vspd.Client{
Expand All @@ -90,6 +98,12 @@ func New(cfg Config) (*Client, error) {
return v, nil
}

// SetAccountInfo set the account purchase information
func (c *Client) SetAccountInfo(feeAcc, changeAcc int32) {
c.policy.FeeAcct = uint32(feeAcc)
c.policy.ChangeAcct = uint32(changeAcc)
}

func (c *Client) FeePercentage(ctx context.Context) (float64, error) {
resp, err := c.Client.VspInfo(ctx)
if err != nil {
Expand Down

0 comments on commit b980746

Please sign in to comment.