Skip to content

Commit

Permalink
Fix functionality of purchaseticket API (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjepson authored and alexlyp committed May 10, 2016
1 parent b285971 commit e625cc1
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,25 +763,45 @@ func (c *Client) PurchaseTicketAsync(fromAccount string,
spendLimit dcrutil.Amount, minConf *int, ticketAddress dcrutil.Address,
numTickets *int, poolAddress dcrutil.Address, poolFees *dcrutil.Amount,
expiry *int) FuturePurchaseTicketResult {
// Parse the addresses into pointers to strings
// for the purpose of the command.
var ticketAddrStrPtr *string
// An empty string is used to keep the sendCmd
// passing of the command from accidentally
// removing certain fields. We fill in the
// default values of the other arguments as
// well for the same reason.

minConfVal := 1
if minConf != nil {
minConfVal = *minConf
}

ticketAddrStr := ""
if ticketAddress != nil {
ticketAddrStr := ticketAddress.EncodeAddress()
ticketAddrStrPtr = &ticketAddrStr
ticketAddrStr = ticketAddress.EncodeAddress()
}

numTicketsVal := 1
if numTickets != nil {
numTicketsVal = *numTickets
}

var poolAddrStrPtr *string
poolAddrStr := ""
if poolAddress != nil {
poolAddrStr := poolAddress.EncodeAddress()
poolAddrStrPtr = &poolAddrStr
poolAddrStr = poolAddress.EncodeAddress()
}

poolFeesFloat := 0.0
if poolFees != nil {
poolFeesFloat = poolFees.ToCoin()
}

poolFeesFloat := poolFees.ToCoin()
expiryVal := 0
if expiry != nil {
expiryVal = *expiry
}

cmd := dcrjson.NewPurchaseTicketCmd(fromAccount, spendLimit.ToCoin(),
minConf, ticketAddrStrPtr, numTickets, poolAddrStrPtr, &poolFeesFloat,
expiry, nil)
&minConfVal, &ticketAddrStr, &numTicketsVal, &poolAddrStr,
&poolFeesFloat, &expiryVal, nil)

return c.sendCmd(cmd)
}
Expand Down

0 comments on commit e625cc1

Please sign in to comment.