-
Notifications
You must be signed in to change notification settings - Fork 296
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
dcrjson: Add SweepAccountCmd & SweepAccountResult. #1027
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to these requested changes, there should also be tests for encoding and decoding the requests
dcrjson/dcrwalletextcmds.go
Outdated
|
||
// SweepAccountCmd defines the sweep account JSON-RPC command. | ||
type SweepAccountCmd struct { | ||
SourceAccount uint32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the json-rpc api uses account names (strings) to refer to accounts
dcrjson/dcrwalletextcmds.go
Outdated
type OutputDestination struct { | ||
Address string | ||
Script []byte | ||
ScriptVersion uint32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably don't need the script and script version, and can just work with an address string instead of this type. P2SH is a better idea anyways for using custom scripts
dcrjson/dcrwalletextcmds.go
Outdated
type SweepAccountCmd struct { | ||
SourceAccount uint32 | ||
RequiredConfirmations uint32 | ||
FeePerKb dcrutil.Amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since json-rpc request parameters are positional, and we want the required confirmations and fee to be configurable but use the wallet defaults, these two must come last.
Additionally, the json-rpc api uses json numbers between 0-21M when referring to amounts, so this must be a float64 (we should not be importing dcrutil at all here)
dcrjson/dcrwalletextcmds.go
Outdated
SourceAccount uint32 | ||
RequiredConfirmations uint32 | ||
FeePerKb dcrutil.Amount | ||
ChangeDestination *OutputDestination |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is ChangeDestination where the account is swept to? I'm assuming so, but this needs a different name. Perhaps just DestinationAddress string
(see comments above about not needing the scripts).
dcrjson/dcrwalletextcmds.go
Outdated
} | ||
|
||
// NewSweepAccountCmd returns a new instance which can be used to issue a JSON-RPC SweepAccountCmd command. | ||
func NewSweepAccountCmd(sourceAccount uint32, requiredConfs uint32, feePerKb *dcrutil.Amount, changeDestination *OutputDestination) *SweepAccountCmd { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after reordering the request parameters in the struct, these should be reordered as well.
dcrjson/dcrwalletextresults.go
Outdated
@@ -5,6 +5,8 @@ | |||
|
|||
package dcrjson | |||
|
|||
import "github.com/decred/dcrd/dcrutil" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no dcrutil import, use float64 for amounts
dcrjson/dcrwalletextresults.go
Outdated
// SweepAccountResult models the data returned from the sweepaccount | ||
// command. | ||
type SweepAccountResult struct { | ||
UnsignedTransaction []byte `json:"unsignedTransaction"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
binary data must be a hexadecimal string in the json-rpc api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, the json struct tags must use all lowercase for consistency with the rest of the api.
29fbc2b
to
6a461c8
Compare
No description provided.