Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix functionality of purchaseticket API #19

Merged
merged 1 commit into from
May 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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