Skip to content

Commit

Permalink
Allow passing an empty string for purchaseticket addresses
Browse files Browse the repository at this point in the history
The purchaseticket RPC would previously fail if the ticket address
or pool address was undeclared (), not allowing the end user to
set the ticket expiry if either was absent. This corrects this
problem by skipping assignment if it is .
  • Loading branch information
cjepson committed Apr 20, 2016
1 parent 5d77ddb commit 0740964
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions rpc/legacyrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -2331,11 +2331,13 @@ func PurchaseTicket(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
// Set ticket address if specified.
var ticketAddr dcrutil.Address
if cmd.TicketAddress != nil {
addr, err := decodeAddress(*cmd.TicketAddress, w.ChainParams())
if err != nil {
return nil, err
if *cmd.TicketAddress != "" {
addr, err := decodeAddress(*cmd.TicketAddress, w.ChainParams())
if err != nil {
return nil, err
}
ticketAddr = addr
}
ticketAddr = addr
}

numTickets := 1
Expand All @@ -2349,20 +2351,22 @@ func PurchaseTicket(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
var poolAddr dcrutil.Address
var poolFee dcrutil.Amount
if cmd.PoolAddress != nil {
addr, err := decodeAddress(*cmd.PoolAddress, w.ChainParams())
if err != nil {
return nil, err
}
poolAddr = addr
if *cmd.PoolAddress != "" {
addr, err := decodeAddress(*cmd.PoolAddress, w.ChainParams())
if err != nil {
return nil, err
}
poolAddr = addr

// Attempt to get the amount to send to
// the pool after.
if cmd.PoolFees == nil {
return nil, fmt.Errorf("gave pool address but no pool fee")
}
poolFee, err = dcrutil.NewAmount(*cmd.PoolFees)
if err != nil {
return nil, err
// Attempt to get the amount to send to
// the pool after.
if cmd.PoolFees == nil {
return nil, fmt.Errorf("gave pool address but no pool fee")
}
poolFee, err = dcrutil.NewAmount(*cmd.PoolFees)
if err != nil {
return nil, err
}
}
}

Expand Down

0 comments on commit 0740964

Please sign in to comment.