Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 2 additions & 11 deletions internal/rpc/jsonrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ import (

// API version constants
const (
jsonrpcSemverString = "10.0.0"
jsonrpcSemverMajor = 10
jsonrpcSemverString = "11.0.0"
jsonrpcSemverMajor = 11
jsonrpcSemverMinor = 0
jsonrpcSemverPatch = 0
)
Expand Down Expand Up @@ -3293,7 +3293,6 @@ func (s *Server) lockUnspent(ctx context.Context, icmd any) (any, error) {
// using all currently available funds. If the ticket could not be purchased
// because there are not enough eligible funds, an error will be returned.
func (s *Server) purchaseTicket(ctx context.Context, icmd any) (any, error) {
// Enforce valid and positive spend limit.
cmd := icmd.(*types.PurchaseTicketCmd)
w, ok := s.walletLoader.LoadedWallet()
if !ok {
Expand All @@ -3305,14 +3304,6 @@ func (s *Server) purchaseTicket(ctx context.Context, icmd any) (any, error) {
return nil, err
}

spendLimit, err := dcrutil.NewAmount(cmd.SpendLimit)
if err != nil {
return nil, rpcError(dcrjson.ErrRPCInvalidParameter, err)
}
if spendLimit < 0 {
return nil, rpcErrorf(dcrjson.ErrRPCInvalidParameter, "negative spend limit")
}

account, err := w.AccountNumber(ctx, cmd.FromAccount)
if err != nil {
if errors.Is(err, errors.NotExist) {
Expand Down
4 changes: 2 additions & 2 deletions internal/rpc/jsonrpc/rpcserverhelp.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func helpDescsEnUS() map[string]string {
"mixaccount": "mixaccount\n\nMix all outputs of an account.\n\nArguments:\nNone\n\nResult:\nNothing\n",
"mixoutput": "mixoutput \"outpoint\"\n\nMix a specific output.\n\nArguments:\n1. outpoint (string, required) Outpoint (in form \"txhash:index\") to mix\n\nResult:\nNothing\n",
"processunmanagedticket": "processunmanagedticket \"tickethash\"\n\nProcesses tickets for vsp client based on ticket hash.\n\nArguments:\n1. tickethash (string, required) The ticket hash of ticket to be processed by the vsp client.\n\nResult:\nNothing\n",
"purchaseticket": "purchaseticket \"fromaccount\" spendlimit (minconf=1 numtickets=1 expiry \"comment\" dontsigntx)\n\nPurchase ticket using available funds.\n\nArguments:\n1. fromaccount (string, required) The account to use for purchase (default=\"default\")\n2. spendlimit (numeric, required) Limit on the amount to spend on ticket\n3. minconf (numeric, optional, default=1) Minimum number of block confirmations required\n4. numtickets (numeric, optional, default=1) The number of tickets to purchase\n5. expiry (numeric, optional) Height at which the purchase tickets expire\n6. comment (string, optional) Unused\n7. dontsigntx (boolean, optional) Return unsigned split and ticket transactions instead of signing and publishing\n\nResult:\n\"value\" (string) Hash of the resulting ticket\n",
"purchaseticket": "purchaseticket \"fromaccount\" (minconf=1 numtickets=1 expiry \"comment\" dontsigntx)\n\nPurchase ticket using available funds.\n\nArguments:\n1. fromaccount (string, required) The account to use for purchase (default=\"default\")\n2. minconf (numeric, optional, default=1) Minimum number of block confirmations required\n3. numtickets (numeric, optional, default=1) The number of tickets to purchase\n4. expiry (numeric, optional) Height at which the purchase tickets expire\n5. comment (string, optional) Unused\n6. dontsigntx (boolean, optional) Return unsigned split and ticket transactions instead of signing and publishing\n\nResult:\n\"value\" (string) Hash of the resulting ticket\n",
"redeemmultisigout": "redeemmultisigout \"hash\" index tree (\"address\")\n\nTakes the input and constructs a P2PKH paying to the specified address.\n\nArguments:\n1. hash (string, required) Hash of the input transaction\n2. index (numeric, required) Idx of the input transaction\n3. tree (numeric, required) Tree the transaction is on.\n4. address (string, optional) Address to pay to.\n\nResult:\n{\n \"hex\": \"value\", (string) Resulting hash.\n \"complete\": true|false, (boolean) Shows if opperation was completed.\n \"errors\": [{ (array of object) Any errors generated.\n \"txid\": \"value\", (string) The transaction hash of the referenced previous output\n \"vout\": n, (numeric) The output index of the referenced previous output\n \"scriptSig\": \"value\", (string) The hex-encoded signature script\n \"sequence\": n, (numeric) Script sequence number\n \"error\": \"value\", (string) Verification or signing error related to the input\n },...], \n} \n",
"redeemmultisigouts": "redeemmultisigouts \"fromscraddress\" (\"toaddress\" number)\n\nTakes a hash, looks up all unspent outpoints and generates list artially signed transactions spending to either an address specified or internal addresses\n\nArguments:\n1. fromscraddress (string, required) Input script hash address.\n2. toaddress (string, optional) Address to look for (if not internal addresses).\n3. number (numeric, optional) Number of outpoints found.\n\nResult:\n{\n \"hex\": \"value\", (string) Resulting hash.\n \"complete\": true|false, (boolean) Shows if opperation was completed.\n \"errors\": [{ (array of object) Any errors generated.\n \"txid\": \"value\", (string) The transaction hash of the referenced previous output\n \"vout\": n, (numeric) The output index of the referenced previous output\n \"scriptSig\": \"value\", (string) The hex-encoded signature script\n \"sequence\": n, (numeric) Script sequence number\n \"error\": \"value\", (string) Verification or signing error related to the input\n },...], \n} \n",
"renameaccount": "renameaccount \"oldaccount\" \"newaccount\"\n\nRenames an account.\n\nArguments:\n1. oldaccount (string, required) The old account name to rename\n2. newaccount (string, required) The new name for the account\n\nResult:\nNothing\n",
Expand Down Expand Up @@ -114,4 +114,4 @@ var localeHelpDescs = map[string]func() map[string]string{
"en_US": helpDescsEnUS,
}

var requestUsages = "abandontransaction \"hash\"\naccountaddressindex \"account\" branch\naccountsyncaddressindex \"account\" branch index\naccountunlocked \"account\"\naddmultisigaddress nrequired [\"key\",...] (\"account\")\naddtransaction \"blockhash\" \"transaction\"\nauditreuse (since)\nconsolidate inputs (\"account\" \"address\")\ncreatemultisig nrequired [\"key\",...]\ncreatenewaccount \"account\"\ncreaterawtransaction [{\"amount\":n.nnn,\"txid\":\"value\",\"vout\":n,\"tree\":n},...] {\"address\":amount,...} (locktime expiry)\ncreatesignature \"address\" inputindex hashtype \"previouspkscript\" \"serializedtransaction\"\ndebuglevel \"levelspec\"\ndisapprovepercent\ndiscoverusage (\"startblock\" discoveraccounts gaplimit)\ndumpprivkey \"address\"\nfundrawtransaction \"hexstring\" \"fundaccount\" ({\"changeaddress\":changeaddress,\"feerate\":feerate,\"conftarget\":conftarget})\ngetaccount \"address\"\ngetaccountaddress \"account\"\ngetaddressesbyaccount \"account\"\ngetbalance (\"account\" minconf=1)\ngetbestblock\ngetbestblockhash\ngetblockcount\ngetblockhash index\ngetblockheader \"hash\" (verbose=true)\ngetblock \"hash\" (verbose=true verbosetx=false)\ngetcoinjoinsbyacct\ngetcurrentnet\ngetinfo\ngetmasterpubkey (\"account\")\ngetmultisigoutinfo \"hash\" index\ngetnewaddress (\"account\" \"gappolicy\")\ngetpeerinfo\ngetrawchangeaddress (\"account\")\ngetreceivedbyaccount \"account\" (minconf=1)\ngetreceivedbyaddress \"address\" (minconf=1)\ngetstakeinfo\ngettickets includeimmature\ngettransaction \"txid\" (includewatchonly=false)\ngettxout \"txid\" vout tree (includemempool=true)\ngetunconfirmedbalance (\"account\")\ngetvotechoices (\"tickethash\")\ngetwalletfee\ngetcfilterv2 \"blockhash\"\nhelp (\"command\")\nimportcfiltersv2 startheight [\"filter\",...]\nimportprivkey \"privkey\" (\"label\" rescan=true scanfrom)\nimportpubkey \"pubkey\" (\"label\" rescan=true scanfrom)\nimportscript \"hex\" (rescan=true scanfrom)\nimportxpub \"name\" \"xpub\"\nlistaccounts (minconf=1)\nlistaddresstransactions [\"address\",...] (\"account\")\nlistalltransactions (\"account\")\nlistlockunspent (\"account\")\nlistreceivedbyaccount (minconf=1 includeempty=false includewatchonly=false)\nlistreceivedbyaddress (minconf=1 includeempty=false includewatchonly=false)\nlistsinceblock (\"blockhash\" targetconfirmations=1 includewatchonly=false)\nlisttransactions (\"account\" count=10 from=0 includewatchonly=false)\nlistunspent (minconf=1 maxconf=9999999 [\"address\",...] \"account\")\nlockaccount \"account\"\nlockunspent unlock [{\"amount\":n.nnn,\"txid\":\"value\",\"vout\":n,\"tree\":n},...]\nmixaccount\nmixoutput \"outpoint\"\nprocessunmanagedticket \"tickethash\"\npurchaseticket \"fromaccount\" spendlimit (minconf=1 numtickets=1 expiry \"comment\" dontsigntx)\nredeemmultisigout \"hash\" index tree (\"address\")\nredeemmultisigouts \"fromscraddress\" (\"toaddress\" number)\nrenameaccount \"oldaccount\" \"newaccount\"\nrescanwallet (beginheight=0)\nsendfrom \"fromaccount\" \"toaddress\" amount (minconf=1 \"comment\" \"commentto\")\nsendfromtreasury \"key\" amounts\nsendmany \"fromaccount\" {\"address\":amount,...} (minconf=1 \"comment\")\nsendrawtransaction \"hextx\" (allowhighfees=false)\nsendtoaddress \"address\" amount (\"comment\" \"commentto\")\nsendtomultisig \"fromaccount\" amount [\"pubkey\",...] (nrequired=1 minconf=1 \"comment\")\nsendtotreasury amount\nsetaccountpassphrase \"account\" \"passphrase\"\nsetdisapprovepercent percent\nsettreasurypolicy \"key\" \"policy\" (\"ticket\")\nsettspendpolicy \"hash\" \"policy\" (\"ticket\")\nsettxfee amount\nsetvotechoice \"agendaid\" \"choiceid\" (\"tickethash\")\nsignmessage \"address\" \"message\"\nsignrawtransaction \"rawtx\" ([{\"txid\":\"value\",\"vout\":n,\"tree\":n,\"scriptpubkey\":\"value\",\"redeemscript\":\"value\"},...] [\"privkey\",...] flags=\"ALL\")\nsignrawtransactions [\"rawtx\",...] (send=true)\nspendoutputs \"account\" [\"previousoutpoint\",...] [{\"address\":\"value\",\"amount\":n.nnn},...]\nsweepaccount \"sourceaccount\" \"destinationaddress\" (requiredconfirmations feeperkb)\nsyncstatus\nticketinfo (startheight=0)\ntreasurypolicy (\"key\" \"ticket\")\ntspendpolicy (\"hash\" \"ticket\")\nunlockaccount \"account\" \"passphrase\"\nvalidateaddress \"address\"\nvalidatepredcp0005cf\nverifymessage \"address\" \"signature\" \"message\"\nversion\nwalletinfo\nwalletislocked\nwalletlock\nwalletpassphrase \"passphrase\" timeout\nwalletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\nwalletpubpassphrasechange \"oldpassphrase\" \"newpassphrase\""
var requestUsages = "abandontransaction \"hash\"\naccountaddressindex \"account\" branch\naccountsyncaddressindex \"account\" branch index\naccountunlocked \"account\"\naddmultisigaddress nrequired [\"key\",...] (\"account\")\naddtransaction \"blockhash\" \"transaction\"\nauditreuse (since)\nconsolidate inputs (\"account\" \"address\")\ncreatemultisig nrequired [\"key\",...]\ncreatenewaccount \"account\"\ncreaterawtransaction [{\"amount\":n.nnn,\"txid\":\"value\",\"vout\":n,\"tree\":n},...] {\"address\":amount,...} (locktime expiry)\ncreatesignature \"address\" inputindex hashtype \"previouspkscript\" \"serializedtransaction\"\ndebuglevel \"levelspec\"\ndisapprovepercent\ndiscoverusage (\"startblock\" discoveraccounts gaplimit)\ndumpprivkey \"address\"\nfundrawtransaction \"hexstring\" \"fundaccount\" ({\"changeaddress\":changeaddress,\"feerate\":feerate,\"conftarget\":conftarget})\ngetaccount \"address\"\ngetaccountaddress \"account\"\ngetaddressesbyaccount \"account\"\ngetbalance (\"account\" minconf=1)\ngetbestblock\ngetbestblockhash\ngetblockcount\ngetblockhash index\ngetblockheader \"hash\" (verbose=true)\ngetblock \"hash\" (verbose=true verbosetx=false)\ngetcoinjoinsbyacct\ngetcurrentnet\ngetinfo\ngetmasterpubkey (\"account\")\ngetmultisigoutinfo \"hash\" index\ngetnewaddress (\"account\" \"gappolicy\")\ngetpeerinfo\ngetrawchangeaddress (\"account\")\ngetreceivedbyaccount \"account\" (minconf=1)\ngetreceivedbyaddress \"address\" (minconf=1)\ngetstakeinfo\ngettickets includeimmature\ngettransaction \"txid\" (includewatchonly=false)\ngettxout \"txid\" vout tree (includemempool=true)\ngetunconfirmedbalance (\"account\")\ngetvotechoices (\"tickethash\")\ngetwalletfee\ngetcfilterv2 \"blockhash\"\nhelp (\"command\")\nimportcfiltersv2 startheight [\"filter\",...]\nimportprivkey \"privkey\" (\"label\" rescan=true scanfrom)\nimportpubkey \"pubkey\" (\"label\" rescan=true scanfrom)\nimportscript \"hex\" (rescan=true scanfrom)\nimportxpub \"name\" \"xpub\"\nlistaccounts (minconf=1)\nlistaddresstransactions [\"address\",...] (\"account\")\nlistalltransactions (\"account\")\nlistlockunspent (\"account\")\nlistreceivedbyaccount (minconf=1 includeempty=false includewatchonly=false)\nlistreceivedbyaddress (minconf=1 includeempty=false includewatchonly=false)\nlistsinceblock (\"blockhash\" targetconfirmations=1 includewatchonly=false)\nlisttransactions (\"account\" count=10 from=0 includewatchonly=false)\nlistunspent (minconf=1 maxconf=9999999 [\"address\",...] \"account\")\nlockaccount \"account\"\nlockunspent unlock [{\"amount\":n.nnn,\"txid\":\"value\",\"vout\":n,\"tree\":n},...]\nmixaccount\nmixoutput \"outpoint\"\nprocessunmanagedticket \"tickethash\"\npurchaseticket \"fromaccount\" (minconf=1 numtickets=1 expiry \"comment\" dontsigntx)\nredeemmultisigout \"hash\" index tree (\"address\")\nredeemmultisigouts \"fromscraddress\" (\"toaddress\" number)\nrenameaccount \"oldaccount\" \"newaccount\"\nrescanwallet (beginheight=0)\nsendfrom \"fromaccount\" \"toaddress\" amount (minconf=1 \"comment\" \"commentto\")\nsendfromtreasury \"key\" amounts\nsendmany \"fromaccount\" {\"address\":amount,...} (minconf=1 \"comment\")\nsendrawtransaction \"hextx\" (allowhighfees=false)\nsendtoaddress \"address\" amount (\"comment\" \"commentto\")\nsendtomultisig \"fromaccount\" amount [\"pubkey\",...] (nrequired=1 minconf=1 \"comment\")\nsendtotreasury amount\nsetaccountpassphrase \"account\" \"passphrase\"\nsetdisapprovepercent percent\nsettreasurypolicy \"key\" \"policy\" (\"ticket\")\nsettspendpolicy \"hash\" \"policy\" (\"ticket\")\nsettxfee amount\nsetvotechoice \"agendaid\" \"choiceid\" (\"tickethash\")\nsignmessage \"address\" \"message\"\nsignrawtransaction \"rawtx\" ([{\"txid\":\"value\",\"vout\":n,\"tree\":n,\"scriptpubkey\":\"value\",\"redeemscript\":\"value\"},...] [\"privkey\",...] flags=\"ALL\")\nsignrawtransactions [\"rawtx\",...] (send=true)\nspendoutputs \"account\" [\"previousoutpoint\",...] [{\"address\":\"value\",\"amount\":n.nnn},...]\nsweepaccount \"sourceaccount\" \"destinationaddress\" (requiredconfirmations feeperkb)\nsyncstatus\nticketinfo (startheight=0)\ntreasurypolicy (\"key\" \"ticket\")\ntspendpolicy (\"hash\" \"ticket\")\nunlockaccount \"account\" \"passphrase\"\nvalidateaddress \"address\"\nvalidatepredcp0005cf\nverifymessage \"address\" \"signature\" \"message\"\nversion\nwalletinfo\nwalletislocked\nwalletlock\nwalletpassphrase \"passphrase\" timeout\nwalletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\nwalletpubpassphrasechange \"oldpassphrase\" \"newpassphrase\""
10 changes: 2 additions & 8 deletions internal/rpc/rpcserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ import (

// Public API version constants
const (
semverString = "9.0.0"
semverMajor = 9
semverString = "10.0.0"
semverMajor = 10
semverMinor = 0
semverPatch = 0
)
Expand Down Expand Up @@ -1792,12 +1792,6 @@ func (s *walletServer) PurchaseTickets(ctx context.Context,
req *pb.PurchaseTicketsRequest) (*pb.PurchaseTicketsResponse, error) {
// Unmarshall the received data and prepare it as input for the ticket
// purchase request.
spendLimit := dcrutil.Amount(req.SpendLimit)
if spendLimit < 0 {
return nil, status.Errorf(codes.InvalidArgument,
"Negative spend limit given")
}

minConf := int32(req.RequiredConfirmations)

var err error
Expand Down
3 changes: 1 addition & 2 deletions internal/rpchelp/helpdescs_en_US.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2015 The btcsuite developers
// Copyright (c) 2015-2024 The Decred developers
// Copyright (c) 2015-2025 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -685,7 +685,6 @@ var helpDescsEnUS = map[string]string{
// PurchaseTicketCmd help.
"purchaseticket--synopsis": "Purchase ticket using available funds.",
"purchaseticket--result0": "Hash of the resulting ticket",
"purchaseticket-spendlimit": "Limit on the amount to spend on ticket",
"purchaseticket-fromaccount": "The account to use for purchase (default=\"default\")",
"purchaseticket-minconf": "Minimum number of block confirmations required",
"purchaseticket-numtickets": "The number of tickets to purchase",
Expand Down
31 changes: 15 additions & 16 deletions rpc/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -627,22 +627,21 @@ message PublishUnminedTransactionsResponse {}
message PurchaseTicketsRequest {
bytes passphrase = 1;
uint32 account = 2;
int64 spend_limit = 3;
uint32 required_confirmations = 4;
uint32 num_tickets = 5;
uint32 expiry = 6;
int64 tx_fee = 7;
int64 ticket_fee = 8;
bool dont_sign_tx = 9;
bool enable_mixing = 10;
uint32 mixed_account = 11;
uint32 mixed_account_branch = 12;
uint32 mixed_split_account = 13;
uint32 change_account = 14;
string vsp_host = 15;
string vsp_pubkey = 16;
bool use_voting_account = 17;
uint32 voting_account = 18;
uint32 required_confirmations = 3;
uint32 num_tickets = 4;
uint32 expiry = 5;
int64 tx_fee = 6;
int64 ticket_fee = 7;
bool dont_sign_tx = 8;
bool enable_mixing = 9;
uint32 mixed_account = 10;
uint32 mixed_account_branch = 11;
uint32 mixed_split_account = 12;
uint32 change_account = 13;
string vsp_host = 14;
string vsp_pubkey = 15;
bool use_voting_account = 16;
uint32 voting_account = 17;
}
message PurchaseTicketsResponse {
repeated bytes ticket_hashes = 1;
Expand Down
6 changes: 2 additions & 4 deletions rpc/client/dcrwallet/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,11 @@ func (c *Client) SendManyMinConf(ctx context.Context, fromAccount string, amount
// parameter, a nil parameter indicates the default value for the optional
// parameter.
func (c *Client) PurchaseTicket(ctx context.Context, fromAccount string,
spendLimit dcrutil.Amount, minConf *int,
numTickets *int, expiry *int, ticketChange *bool,
minConf *int, numTickets *int, expiry *int, ticketChange *bool,
ticketFee *dcrutil.Amount) ([]*chainhash.Hash, error) {

params := make([]any, 2, 10)
params := make([]any, 1, 9)
params[0] = fromAccount
params[1] = spendLimit.ToCoin()

var skipped int
addParam := func(nonNil bool, value func() any) {
Expand Down
8 changes: 3 additions & 5 deletions rpc/jsonrpc/types/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,20 +678,18 @@ func NewLockUnspentCmd(unlock bool, transactions []dcrdtypes.TransactionInput) *
// unmarshaling of purchaseticket JSON RPC commands.
type PurchaseTicketCmd struct {
FromAccount string
SpendLimit float64 // In Coins
MinConf *int `jsonrpcdefault:"1"`
NumTickets *int `jsonrpcdefault:"1"`
MinConf *int `jsonrpcdefault:"1"`
NumTickets *int `jsonrpcdefault:"1"`
Expiry *int
Comment *string
DontSignTx *bool
}

// NewPurchaseTicketCmd creates a new PurchaseTicketCmd.
func NewPurchaseTicketCmd(fromAccount string, spendLimit float64, minConf *int,
func NewPurchaseTicketCmd(fromAccount string, minConf *int,
numTickets *int, expiry *int, comment *string) *PurchaseTicketCmd {
return &PurchaseTicketCmd{
FromAccount: fromAccount,
SpendLimit: spendLimit,
MinConf: minConf,
NumTickets: numTickets,
Expiry: expiry,
Expand Down
Loading
Loading