github.com/BlockABC/godash@v0.0.0-20191112120524-f4aa3a32c566/btcjson/walletsvrcmds_test.go (about)

     1  // Copyright (c) 2014 The btcsuite developers
     2  // Copyright (c) 2016 The Dash developers
     3  // Use of this source code is governed by an ISC
     4  // license that can be found in the LICENSE file.
     5  
     6  package btcjson_test
     7  
     8  import (
     9  	"bytes"
    10  	"encoding/json"
    11  	"fmt"
    12  	"reflect"
    13  	"testing"
    14  
    15  	"github.com/BlockABC/godash/btcjson"
    16  )
    17  
    18  // TestWalletSvrCmds tests all of the wallet server commands marshal and
    19  // unmarshal into valid results include handling of optional fields being
    20  // omitted in the marshalled command, while optional fields with defaults have
    21  // the default assigned on unmarshalled commands.
    22  func TestWalletSvrCmds(t *testing.T) {
    23  	t.Parallel()
    24  
    25  	testID := int(1)
    26  	tests := []struct {
    27  		name         string
    28  		newCmd       func() (interface{}, error)
    29  		staticCmd    func() interface{}
    30  		marshalled   string
    31  		unmarshalled interface{}
    32  	}{
    33  		{
    34  			name: "addmultisigaddress",
    35  			newCmd: func() (interface{}, error) {
    36  				return btcjson.NewCmd("addmultisigaddress", 2, []string{"031234", "035678"})
    37  			},
    38  			staticCmd: func() interface{} {
    39  				keys := []string{"031234", "035678"}
    40  				return btcjson.NewAddMultisigAddressCmd(2, keys, nil)
    41  			},
    42  			marshalled: `{"jsonrpc":"1.0","method":"addmultisigaddress","params":[2,["031234","035678"]],"id":1}`,
    43  			unmarshalled: &btcjson.AddMultisigAddressCmd{
    44  				NRequired: 2,
    45  				Keys:      []string{"031234", "035678"},
    46  				Account:   nil,
    47  			},
    48  		},
    49  		{
    50  			name: "addmultisigaddress optional",
    51  			newCmd: func() (interface{}, error) {
    52  				return btcjson.NewCmd("addmultisigaddress", 2, []string{"031234", "035678"}, "test")
    53  			},
    54  			staticCmd: func() interface{} {
    55  				keys := []string{"031234", "035678"}
    56  				return btcjson.NewAddMultisigAddressCmd(2, keys, btcjson.String("test"))
    57  			},
    58  			marshalled: `{"jsonrpc":"1.0","method":"addmultisigaddress","params":[2,["031234","035678"],"test"],"id":1}`,
    59  			unmarshalled: &btcjson.AddMultisigAddressCmd{
    60  				NRequired: 2,
    61  				Keys:      []string{"031234", "035678"},
    62  				Account:   btcjson.String("test"),
    63  			},
    64  		},
    65  		{
    66  			name: "createmultisig",
    67  			newCmd: func() (interface{}, error) {
    68  				return btcjson.NewCmd("createmultisig", 2, []string{"031234", "035678"})
    69  			},
    70  			staticCmd: func() interface{} {
    71  				keys := []string{"031234", "035678"}
    72  				return btcjson.NewCreateMultisigCmd(2, keys)
    73  			},
    74  			marshalled: `{"jsonrpc":"1.0","method":"createmultisig","params":[2,["031234","035678"]],"id":1}`,
    75  			unmarshalled: &btcjson.CreateMultisigCmd{
    76  				NRequired: 2,
    77  				Keys:      []string{"031234", "035678"},
    78  			},
    79  		},
    80  		{
    81  			name: "dumpprivkey",
    82  			newCmd: func() (interface{}, error) {
    83  				return btcjson.NewCmd("dumpprivkey", "1Address")
    84  			},
    85  			staticCmd: func() interface{} {
    86  				return btcjson.NewDumpPrivKeyCmd("1Address")
    87  			},
    88  			marshalled: `{"jsonrpc":"1.0","method":"dumpprivkey","params":["1Address"],"id":1}`,
    89  			unmarshalled: &btcjson.DumpPrivKeyCmd{
    90  				Address: "1Address",
    91  			},
    92  		},
    93  		{
    94  			name: "encryptwallet",
    95  			newCmd: func() (interface{}, error) {
    96  				return btcjson.NewCmd("encryptwallet", "pass")
    97  			},
    98  			staticCmd: func() interface{} {
    99  				return btcjson.NewEncryptWalletCmd("pass")
   100  			},
   101  			marshalled: `{"jsonrpc":"1.0","method":"encryptwallet","params":["pass"],"id":1}`,
   102  			unmarshalled: &btcjson.EncryptWalletCmd{
   103  				Passphrase: "pass",
   104  			},
   105  		},
   106  		{
   107  			name: "estimatefee",
   108  			newCmd: func() (interface{}, error) {
   109  				return btcjson.NewCmd("estimatefee", 6)
   110  			},
   111  			staticCmd: func() interface{} {
   112  				return btcjson.NewEstimateFeeCmd(6)
   113  			},
   114  			marshalled: `{"jsonrpc":"1.0","method":"estimatefee","params":[6],"id":1}`,
   115  			unmarshalled: &btcjson.EstimateFeeCmd{
   116  				NumBlocks: 6,
   117  			},
   118  		},
   119  		{
   120  			name: "estimatepriority",
   121  			newCmd: func() (interface{}, error) {
   122  				return btcjson.NewCmd("estimatepriority", 6)
   123  			},
   124  			staticCmd: func() interface{} {
   125  				return btcjson.NewEstimatePriorityCmd(6)
   126  			},
   127  			marshalled: `{"jsonrpc":"1.0","method":"estimatepriority","params":[6],"id":1}`,
   128  			unmarshalled: &btcjson.EstimatePriorityCmd{
   129  				NumBlocks: 6,
   130  			},
   131  		},
   132  		{
   133  			name: "getaccount",
   134  			newCmd: func() (interface{}, error) {
   135  				return btcjson.NewCmd("getaccount", "1Address")
   136  			},
   137  			staticCmd: func() interface{} {
   138  				return btcjson.NewGetAccountCmd("1Address")
   139  			},
   140  			marshalled: `{"jsonrpc":"1.0","method":"getaccount","params":["1Address"],"id":1}`,
   141  			unmarshalled: &btcjson.GetAccountCmd{
   142  				Address: "1Address",
   143  			},
   144  		},
   145  		{
   146  			name: "getaccountaddress",
   147  			newCmd: func() (interface{}, error) {
   148  				return btcjson.NewCmd("getaccountaddress", "acct")
   149  			},
   150  			staticCmd: func() interface{} {
   151  				return btcjson.NewGetAccountAddressCmd("acct")
   152  			},
   153  			marshalled: `{"jsonrpc":"1.0","method":"getaccountaddress","params":["acct"],"id":1}`,
   154  			unmarshalled: &btcjson.GetAccountAddressCmd{
   155  				Account: "acct",
   156  			},
   157  		},
   158  		{
   159  			name: "getaddressesbyaccount",
   160  			newCmd: func() (interface{}, error) {
   161  				return btcjson.NewCmd("getaddressesbyaccount", "acct")
   162  			},
   163  			staticCmd: func() interface{} {
   164  				return btcjson.NewGetAddressesByAccountCmd("acct")
   165  			},
   166  			marshalled: `{"jsonrpc":"1.0","method":"getaddressesbyaccount","params":["acct"],"id":1}`,
   167  			unmarshalled: &btcjson.GetAddressesByAccountCmd{
   168  				Account: "acct",
   169  			},
   170  		},
   171  		{
   172  			name: "getbalance",
   173  			newCmd: func() (interface{}, error) {
   174  				return btcjson.NewCmd("getbalance")
   175  			},
   176  			staticCmd: func() interface{} {
   177  				return btcjson.NewGetBalanceCmd(nil, nil)
   178  			},
   179  			marshalled: `{"jsonrpc":"1.0","method":"getbalance","params":[],"id":1}`,
   180  			unmarshalled: &btcjson.GetBalanceCmd{
   181  				Account: nil,
   182  				MinConf: btcjson.Int(1),
   183  			},
   184  		},
   185  		{
   186  			name: "getbalance optional1",
   187  			newCmd: func() (interface{}, error) {
   188  				return btcjson.NewCmd("getbalance", "acct")
   189  			},
   190  			staticCmd: func() interface{} {
   191  				return btcjson.NewGetBalanceCmd(btcjson.String("acct"), nil)
   192  			},
   193  			marshalled: `{"jsonrpc":"1.0","method":"getbalance","params":["acct"],"id":1}`,
   194  			unmarshalled: &btcjson.GetBalanceCmd{
   195  				Account: btcjson.String("acct"),
   196  				MinConf: btcjson.Int(1),
   197  			},
   198  		},
   199  		{
   200  			name: "getbalance optional2",
   201  			newCmd: func() (interface{}, error) {
   202  				return btcjson.NewCmd("getbalance", "acct", 6)
   203  			},
   204  			staticCmd: func() interface{} {
   205  				return btcjson.NewGetBalanceCmd(btcjson.String("acct"), btcjson.Int(6))
   206  			},
   207  			marshalled: `{"jsonrpc":"1.0","method":"getbalance","params":["acct",6],"id":1}`,
   208  			unmarshalled: &btcjson.GetBalanceCmd{
   209  				Account: btcjson.String("acct"),
   210  				MinConf: btcjson.Int(6),
   211  			},
   212  		},
   213  		{
   214  			name: "getnewaddress",
   215  			newCmd: func() (interface{}, error) {
   216  				return btcjson.NewCmd("getnewaddress")
   217  			},
   218  			staticCmd: func() interface{} {
   219  				return btcjson.NewGetNewAddressCmd(nil)
   220  			},
   221  			marshalled: `{"jsonrpc":"1.0","method":"getnewaddress","params":[],"id":1}`,
   222  			unmarshalled: &btcjson.GetNewAddressCmd{
   223  				Account: nil,
   224  			},
   225  		},
   226  		{
   227  			name: "getnewaddress optional",
   228  			newCmd: func() (interface{}, error) {
   229  				return btcjson.NewCmd("getnewaddress", "acct")
   230  			},
   231  			staticCmd: func() interface{} {
   232  				return btcjson.NewGetNewAddressCmd(btcjson.String("acct"))
   233  			},
   234  			marshalled: `{"jsonrpc":"1.0","method":"getnewaddress","params":["acct"],"id":1}`,
   235  			unmarshalled: &btcjson.GetNewAddressCmd{
   236  				Account: btcjson.String("acct"),
   237  			},
   238  		},
   239  		{
   240  			name: "getrawchangeaddress",
   241  			newCmd: func() (interface{}, error) {
   242  				return btcjson.NewCmd("getrawchangeaddress")
   243  			},
   244  			staticCmd: func() interface{} {
   245  				return btcjson.NewGetRawChangeAddressCmd(nil)
   246  			},
   247  			marshalled: `{"jsonrpc":"1.0","method":"getrawchangeaddress","params":[],"id":1}`,
   248  			unmarshalled: &btcjson.GetRawChangeAddressCmd{
   249  				Account: nil,
   250  			},
   251  		},
   252  		{
   253  			name: "getrawchangeaddress optional",
   254  			newCmd: func() (interface{}, error) {
   255  				return btcjson.NewCmd("getrawchangeaddress", "acct")
   256  			},
   257  			staticCmd: func() interface{} {
   258  				return btcjson.NewGetRawChangeAddressCmd(btcjson.String("acct"))
   259  			},
   260  			marshalled: `{"jsonrpc":"1.0","method":"getrawchangeaddress","params":["acct"],"id":1}`,
   261  			unmarshalled: &btcjson.GetRawChangeAddressCmd{
   262  				Account: btcjson.String("acct"),
   263  			},
   264  		},
   265  		{
   266  			name: "getreceivedbyaccount",
   267  			newCmd: func() (interface{}, error) {
   268  				return btcjson.NewCmd("getreceivedbyaccount", "acct")
   269  			},
   270  			staticCmd: func() interface{} {
   271  				return btcjson.NewGetReceivedByAccountCmd("acct", nil)
   272  			},
   273  			marshalled: `{"jsonrpc":"1.0","method":"getreceivedbyaccount","params":["acct"],"id":1}`,
   274  			unmarshalled: &btcjson.GetReceivedByAccountCmd{
   275  				Account: "acct",
   276  				MinConf: btcjson.Int(1),
   277  			},
   278  		},
   279  		{
   280  			name: "getreceivedbyaccount optional",
   281  			newCmd: func() (interface{}, error) {
   282  				return btcjson.NewCmd("getreceivedbyaccount", "acct", 6)
   283  			},
   284  			staticCmd: func() interface{} {
   285  				return btcjson.NewGetReceivedByAccountCmd("acct", btcjson.Int(6))
   286  			},
   287  			marshalled: `{"jsonrpc":"1.0","method":"getreceivedbyaccount","params":["acct",6],"id":1}`,
   288  			unmarshalled: &btcjson.GetReceivedByAccountCmd{
   289  				Account: "acct",
   290  				MinConf: btcjson.Int(6),
   291  			},
   292  		},
   293  		{
   294  			name: "getreceivedbyaddress",
   295  			newCmd: func() (interface{}, error) {
   296  				return btcjson.NewCmd("getreceivedbyaddress", "1Address")
   297  			},
   298  			staticCmd: func() interface{} {
   299  				return btcjson.NewGetReceivedByAddressCmd("1Address", nil)
   300  			},
   301  			marshalled: `{"jsonrpc":"1.0","method":"getreceivedbyaddress","params":["1Address"],"id":1}`,
   302  			unmarshalled: &btcjson.GetReceivedByAddressCmd{
   303  				Address: "1Address",
   304  				MinConf: btcjson.Int(1),
   305  			},
   306  		},
   307  		{
   308  			name: "getreceivedbyaddress optional",
   309  			newCmd: func() (interface{}, error) {
   310  				return btcjson.NewCmd("getreceivedbyaddress", "1Address", 6)
   311  			},
   312  			staticCmd: func() interface{} {
   313  				return btcjson.NewGetReceivedByAddressCmd("1Address", btcjson.Int(6))
   314  			},
   315  			marshalled: `{"jsonrpc":"1.0","method":"getreceivedbyaddress","params":["1Address",6],"id":1}`,
   316  			unmarshalled: &btcjson.GetReceivedByAddressCmd{
   317  				Address: "1Address",
   318  				MinConf: btcjson.Int(6),
   319  			},
   320  		},
   321  		{
   322  			name: "gettransaction",
   323  			newCmd: func() (interface{}, error) {
   324  				return btcjson.NewCmd("gettransaction", "123")
   325  			},
   326  			staticCmd: func() interface{} {
   327  				return btcjson.NewGetTransactionCmd("123", nil)
   328  			},
   329  			marshalled: `{"jsonrpc":"1.0","method":"gettransaction","params":["123"],"id":1}`,
   330  			unmarshalled: &btcjson.GetTransactionCmd{
   331  				Txid:             "123",
   332  				IncludeWatchOnly: btcjson.Bool(false),
   333  			},
   334  		},
   335  		{
   336  			name: "gettransaction optional",
   337  			newCmd: func() (interface{}, error) {
   338  				return btcjson.NewCmd("gettransaction", "123", true)
   339  			},
   340  			staticCmd: func() interface{} {
   341  				return btcjson.NewGetTransactionCmd("123", btcjson.Bool(true))
   342  			},
   343  			marshalled: `{"jsonrpc":"1.0","method":"gettransaction","params":["123",true],"id":1}`,
   344  			unmarshalled: &btcjson.GetTransactionCmd{
   345  				Txid:             "123",
   346  				IncludeWatchOnly: btcjson.Bool(true),
   347  			},
   348  		},
   349  		{
   350  			name: "getwalletinfo",
   351  			newCmd: func() (interface{}, error) {
   352  				return btcjson.NewCmd("getwalletinfo")
   353  			},
   354  			staticCmd: func() interface{} {
   355  				return btcjson.NewGetWalletInfoCmd()
   356  			},
   357  			marshalled:   `{"jsonrpc":"1.0","method":"getwalletinfo","params":[],"id":1}`,
   358  			unmarshalled: &btcjson.GetWalletInfoCmd{},
   359  		},
   360  		{
   361  			name: "importprivkey",
   362  			newCmd: func() (interface{}, error) {
   363  				return btcjson.NewCmd("importprivkey", "abc")
   364  			},
   365  			staticCmd: func() interface{} {
   366  				return btcjson.NewImportPrivKeyCmd("abc", nil, nil)
   367  			},
   368  			marshalled: `{"jsonrpc":"1.0","method":"importprivkey","params":["abc"],"id":1}`,
   369  			unmarshalled: &btcjson.ImportPrivKeyCmd{
   370  				PrivKey: "abc",
   371  				Label:   nil,
   372  				Rescan:  btcjson.Bool(true),
   373  			},
   374  		},
   375  		{
   376  			name: "importprivkey optional1",
   377  			newCmd: func() (interface{}, error) {
   378  				return btcjson.NewCmd("importprivkey", "abc", "label")
   379  			},
   380  			staticCmd: func() interface{} {
   381  				return btcjson.NewImportPrivKeyCmd("abc", btcjson.String("label"), nil)
   382  			},
   383  			marshalled: `{"jsonrpc":"1.0","method":"importprivkey","params":["abc","label"],"id":1}`,
   384  			unmarshalled: &btcjson.ImportPrivKeyCmd{
   385  				PrivKey: "abc",
   386  				Label:   btcjson.String("label"),
   387  				Rescan:  btcjson.Bool(true),
   388  			},
   389  		},
   390  		{
   391  			name: "importprivkey optional2",
   392  			newCmd: func() (interface{}, error) {
   393  				return btcjson.NewCmd("importprivkey", "abc", "label", false)
   394  			},
   395  			staticCmd: func() interface{} {
   396  				return btcjson.NewImportPrivKeyCmd("abc", btcjson.String("label"), btcjson.Bool(false))
   397  			},
   398  			marshalled: `{"jsonrpc":"1.0","method":"importprivkey","params":["abc","label",false],"id":1}`,
   399  			unmarshalled: &btcjson.ImportPrivKeyCmd{
   400  				PrivKey: "abc",
   401  				Label:   btcjson.String("label"),
   402  				Rescan:  btcjson.Bool(false),
   403  			},
   404  		},
   405  		{
   406  			name: "keypoolrefill",
   407  			newCmd: func() (interface{}, error) {
   408  				return btcjson.NewCmd("keypoolrefill")
   409  			},
   410  			staticCmd: func() interface{} {
   411  				return btcjson.NewKeyPoolRefillCmd(nil)
   412  			},
   413  			marshalled: `{"jsonrpc":"1.0","method":"keypoolrefill","params":[],"id":1}`,
   414  			unmarshalled: &btcjson.KeyPoolRefillCmd{
   415  				NewSize: btcjson.Uint(100),
   416  			},
   417  		},
   418  		{
   419  			name: "keypoolrefill optional",
   420  			newCmd: func() (interface{}, error) {
   421  				return btcjson.NewCmd("keypoolrefill", 200)
   422  			},
   423  			staticCmd: func() interface{} {
   424  				return btcjson.NewKeyPoolRefillCmd(btcjson.Uint(200))
   425  			},
   426  			marshalled: `{"jsonrpc":"1.0","method":"keypoolrefill","params":[200],"id":1}`,
   427  			unmarshalled: &btcjson.KeyPoolRefillCmd{
   428  				NewSize: btcjson.Uint(200),
   429  			},
   430  		},
   431  		{
   432  			name: "listaccounts",
   433  			newCmd: func() (interface{}, error) {
   434  				return btcjson.NewCmd("listaccounts")
   435  			},
   436  			staticCmd: func() interface{} {
   437  				return btcjson.NewListAccountsCmd(nil)
   438  			},
   439  			marshalled: `{"jsonrpc":"1.0","method":"listaccounts","params":[],"id":1}`,
   440  			unmarshalled: &btcjson.ListAccountsCmd{
   441  				MinConf: btcjson.Int(1),
   442  			},
   443  		},
   444  		{
   445  			name: "listaccounts optional",
   446  			newCmd: func() (interface{}, error) {
   447  				return btcjson.NewCmd("listaccounts", 6)
   448  			},
   449  			staticCmd: func() interface{} {
   450  				return btcjson.NewListAccountsCmd(btcjson.Int(6))
   451  			},
   452  			marshalled: `{"jsonrpc":"1.0","method":"listaccounts","params":[6],"id":1}`,
   453  			unmarshalled: &btcjson.ListAccountsCmd{
   454  				MinConf: btcjson.Int(6),
   455  			},
   456  		},
   457  		{
   458  			name: "listaddressgroupings",
   459  			newCmd: func() (interface{}, error) {
   460  				return btcjson.NewCmd("listaddressgroupings")
   461  			},
   462  			staticCmd: func() interface{} {
   463  				return btcjson.NewListAddressGroupingsCmd()
   464  			},
   465  			marshalled:   `{"jsonrpc":"1.0","method":"listaddressgroupings","params":[],"id":1}`,
   466  			unmarshalled: &btcjson.ListAddressGroupingsCmd{},
   467  		},
   468  		{
   469  			name: "listlockunspent",
   470  			newCmd: func() (interface{}, error) {
   471  				return btcjson.NewCmd("listlockunspent")
   472  			},
   473  			staticCmd: func() interface{} {
   474  				return btcjson.NewListLockUnspentCmd()
   475  			},
   476  			marshalled:   `{"jsonrpc":"1.0","method":"listlockunspent","params":[],"id":1}`,
   477  			unmarshalled: &btcjson.ListLockUnspentCmd{},
   478  		},
   479  		{
   480  			name: "listreceivedbyaccount",
   481  			newCmd: func() (interface{}, error) {
   482  				return btcjson.NewCmd("listreceivedbyaccount")
   483  			},
   484  			staticCmd: func() interface{} {
   485  				return btcjson.NewListReceivedByAccountCmd(nil, nil, nil)
   486  			},
   487  			marshalled: `{"jsonrpc":"1.0","method":"listreceivedbyaccount","params":[],"id":1}`,
   488  			unmarshalled: &btcjson.ListReceivedByAccountCmd{
   489  				MinConf:          btcjson.Int(1),
   490  				IncludeEmpty:     btcjson.Bool(false),
   491  				IncludeWatchOnly: btcjson.Bool(false),
   492  			},
   493  		},
   494  		{
   495  			name: "listreceivedbyaccount optional1",
   496  			newCmd: func() (interface{}, error) {
   497  				return btcjson.NewCmd("listreceivedbyaccount", 6)
   498  			},
   499  			staticCmd: func() interface{} {
   500  				return btcjson.NewListReceivedByAccountCmd(btcjson.Int(6), nil, nil)
   501  			},
   502  			marshalled: `{"jsonrpc":"1.0","method":"listreceivedbyaccount","params":[6],"id":1}`,
   503  			unmarshalled: &btcjson.ListReceivedByAccountCmd{
   504  				MinConf:          btcjson.Int(6),
   505  				IncludeEmpty:     btcjson.Bool(false),
   506  				IncludeWatchOnly: btcjson.Bool(false),
   507  			},
   508  		},
   509  		{
   510  			name: "listreceivedbyaccount optional2",
   511  			newCmd: func() (interface{}, error) {
   512  				return btcjson.NewCmd("listreceivedbyaccount", 6, true)
   513  			},
   514  			staticCmd: func() interface{} {
   515  				return btcjson.NewListReceivedByAccountCmd(btcjson.Int(6), btcjson.Bool(true), nil)
   516  			},
   517  			marshalled: `{"jsonrpc":"1.0","method":"listreceivedbyaccount","params":[6,true],"id":1}`,
   518  			unmarshalled: &btcjson.ListReceivedByAccountCmd{
   519  				MinConf:          btcjson.Int(6),
   520  				IncludeEmpty:     btcjson.Bool(true),
   521  				IncludeWatchOnly: btcjson.Bool(false),
   522  			},
   523  		},
   524  		{
   525  			name: "listreceivedbyaccount optional3",
   526  			newCmd: func() (interface{}, error) {
   527  				return btcjson.NewCmd("listreceivedbyaccount", 6, true, false)
   528  			},
   529  			staticCmd: func() interface{} {
   530  				return btcjson.NewListReceivedByAccountCmd(btcjson.Int(6), btcjson.Bool(true), btcjson.Bool(false))
   531  			},
   532  			marshalled: `{"jsonrpc":"1.0","method":"listreceivedbyaccount","params":[6,true,false],"id":1}`,
   533  			unmarshalled: &btcjson.ListReceivedByAccountCmd{
   534  				MinConf:          btcjson.Int(6),
   535  				IncludeEmpty:     btcjson.Bool(true),
   536  				IncludeWatchOnly: btcjson.Bool(false),
   537  			},
   538  		},
   539  		{
   540  			name: "listreceivedbyaddress",
   541  			newCmd: func() (interface{}, error) {
   542  				return btcjson.NewCmd("listreceivedbyaddress")
   543  			},
   544  			staticCmd: func() interface{} {
   545  				return btcjson.NewListReceivedByAddressCmd(nil, nil, nil)
   546  			},
   547  			marshalled: `{"jsonrpc":"1.0","method":"listreceivedbyaddress","params":[],"id":1}`,
   548  			unmarshalled: &btcjson.ListReceivedByAddressCmd{
   549  				MinConf:          btcjson.Int(1),
   550  				IncludeEmpty:     btcjson.Bool(false),
   551  				IncludeWatchOnly: btcjson.Bool(false),
   552  			},
   553  		},
   554  		{
   555  			name: "listreceivedbyaddress optional1",
   556  			newCmd: func() (interface{}, error) {
   557  				return btcjson.NewCmd("listreceivedbyaddress", 6)
   558  			},
   559  			staticCmd: func() interface{} {
   560  				return btcjson.NewListReceivedByAddressCmd(btcjson.Int(6), nil, nil)
   561  			},
   562  			marshalled: `{"jsonrpc":"1.0","method":"listreceivedbyaddress","params":[6],"id":1}`,
   563  			unmarshalled: &btcjson.ListReceivedByAddressCmd{
   564  				MinConf:          btcjson.Int(6),
   565  				IncludeEmpty:     btcjson.Bool(false),
   566  				IncludeWatchOnly: btcjson.Bool(false),
   567  			},
   568  		},
   569  		{
   570  			name: "listreceivedbyaddress optional2",
   571  			newCmd: func() (interface{}, error) {
   572  				return btcjson.NewCmd("listreceivedbyaddress", 6, true)
   573  			},
   574  			staticCmd: func() interface{} {
   575  				return btcjson.NewListReceivedByAddressCmd(btcjson.Int(6), btcjson.Bool(true), nil)
   576  			},
   577  			marshalled: `{"jsonrpc":"1.0","method":"listreceivedbyaddress","params":[6,true],"id":1}`,
   578  			unmarshalled: &btcjson.ListReceivedByAddressCmd{
   579  				MinConf:          btcjson.Int(6),
   580  				IncludeEmpty:     btcjson.Bool(true),
   581  				IncludeWatchOnly: btcjson.Bool(false),
   582  			},
   583  		},
   584  		{
   585  			name: "listreceivedbyaddress optional3",
   586  			newCmd: func() (interface{}, error) {
   587  				return btcjson.NewCmd("listreceivedbyaddress", 6, true, false)
   588  			},
   589  			staticCmd: func() interface{} {
   590  				return btcjson.NewListReceivedByAddressCmd(btcjson.Int(6), btcjson.Bool(true), btcjson.Bool(false))
   591  			},
   592  			marshalled: `{"jsonrpc":"1.0","method":"listreceivedbyaddress","params":[6,true,false],"id":1}`,
   593  			unmarshalled: &btcjson.ListReceivedByAddressCmd{
   594  				MinConf:          btcjson.Int(6),
   595  				IncludeEmpty:     btcjson.Bool(true),
   596  				IncludeWatchOnly: btcjson.Bool(false),
   597  			},
   598  		},
   599  		{
   600  			name: "listsinceblock",
   601  			newCmd: func() (interface{}, error) {
   602  				return btcjson.NewCmd("listsinceblock")
   603  			},
   604  			staticCmd: func() interface{} {
   605  				return btcjson.NewListSinceBlockCmd(nil, nil, nil)
   606  			},
   607  			marshalled: `{"jsonrpc":"1.0","method":"listsinceblock","params":[],"id":1}`,
   608  			unmarshalled: &btcjson.ListSinceBlockCmd{
   609  				BlockHash:           nil,
   610  				TargetConfirmations: btcjson.Int(1),
   611  				IncludeWatchOnly:    btcjson.Bool(false),
   612  			},
   613  		},
   614  		{
   615  			name: "listsinceblock optional1",
   616  			newCmd: func() (interface{}, error) {
   617  				return btcjson.NewCmd("listsinceblock", "123")
   618  			},
   619  			staticCmd: func() interface{} {
   620  				return btcjson.NewListSinceBlockCmd(btcjson.String("123"), nil, nil)
   621  			},
   622  			marshalled: `{"jsonrpc":"1.0","method":"listsinceblock","params":["123"],"id":1}`,
   623  			unmarshalled: &btcjson.ListSinceBlockCmd{
   624  				BlockHash:           btcjson.String("123"),
   625  				TargetConfirmations: btcjson.Int(1),
   626  				IncludeWatchOnly:    btcjson.Bool(false),
   627  			},
   628  		},
   629  		{
   630  			name: "listsinceblock optional2",
   631  			newCmd: func() (interface{}, error) {
   632  				return btcjson.NewCmd("listsinceblock", "123", 6)
   633  			},
   634  			staticCmd: func() interface{} {
   635  				return btcjson.NewListSinceBlockCmd(btcjson.String("123"), btcjson.Int(6), nil)
   636  			},
   637  			marshalled: `{"jsonrpc":"1.0","method":"listsinceblock","params":["123",6],"id":1}`,
   638  			unmarshalled: &btcjson.ListSinceBlockCmd{
   639  				BlockHash:           btcjson.String("123"),
   640  				TargetConfirmations: btcjson.Int(6),
   641  				IncludeWatchOnly:    btcjson.Bool(false),
   642  			},
   643  		},
   644  		{
   645  			name: "listsinceblock optional3",
   646  			newCmd: func() (interface{}, error) {
   647  				return btcjson.NewCmd("listsinceblock", "123", 6, true)
   648  			},
   649  			staticCmd: func() interface{} {
   650  				return btcjson.NewListSinceBlockCmd(btcjson.String("123"), btcjson.Int(6), btcjson.Bool(true))
   651  			},
   652  			marshalled: `{"jsonrpc":"1.0","method":"listsinceblock","params":["123",6,true],"id":1}`,
   653  			unmarshalled: &btcjson.ListSinceBlockCmd{
   654  				BlockHash:           btcjson.String("123"),
   655  				TargetConfirmations: btcjson.Int(6),
   656  				IncludeWatchOnly:    btcjson.Bool(true),
   657  			},
   658  		},
   659  		{
   660  			name: "listtransactions",
   661  			newCmd: func() (interface{}, error) {
   662  				return btcjson.NewCmd("listtransactions")
   663  			},
   664  			staticCmd: func() interface{} {
   665  				return btcjson.NewListTransactionsCmd(nil, nil, nil, nil)
   666  			},
   667  			marshalled: `{"jsonrpc":"1.0","method":"listtransactions","params":[],"id":1}`,
   668  			unmarshalled: &btcjson.ListTransactionsCmd{
   669  				Account:          nil,
   670  				Count:            btcjson.Int(10),
   671  				From:             btcjson.Int(0),
   672  				IncludeWatchOnly: btcjson.Bool(false),
   673  			},
   674  		},
   675  		{
   676  			name: "listtransactions optional1",
   677  			newCmd: func() (interface{}, error) {
   678  				return btcjson.NewCmd("listtransactions", "acct")
   679  			},
   680  			staticCmd: func() interface{} {
   681  				return btcjson.NewListTransactionsCmd(btcjson.String("acct"), nil, nil, nil)
   682  			},
   683  			marshalled: `{"jsonrpc":"1.0","method":"listtransactions","params":["acct"],"id":1}`,
   684  			unmarshalled: &btcjson.ListTransactionsCmd{
   685  				Account:          btcjson.String("acct"),
   686  				Count:            btcjson.Int(10),
   687  				From:             btcjson.Int(0),
   688  				IncludeWatchOnly: btcjson.Bool(false),
   689  			},
   690  		},
   691  		{
   692  			name: "listtransactions optional2",
   693  			newCmd: func() (interface{}, error) {
   694  				return btcjson.NewCmd("listtransactions", "acct", 20)
   695  			},
   696  			staticCmd: func() interface{} {
   697  				return btcjson.NewListTransactionsCmd(btcjson.String("acct"), btcjson.Int(20), nil, nil)
   698  			},
   699  			marshalled: `{"jsonrpc":"1.0","method":"listtransactions","params":["acct",20],"id":1}`,
   700  			unmarshalled: &btcjson.ListTransactionsCmd{
   701  				Account:          btcjson.String("acct"),
   702  				Count:            btcjson.Int(20),
   703  				From:             btcjson.Int(0),
   704  				IncludeWatchOnly: btcjson.Bool(false),
   705  			},
   706  		},
   707  		{
   708  			name: "listtransactions optional3",
   709  			newCmd: func() (interface{}, error) {
   710  				return btcjson.NewCmd("listtransactions", "acct", 20, 1)
   711  			},
   712  			staticCmd: func() interface{} {
   713  				return btcjson.NewListTransactionsCmd(btcjson.String("acct"), btcjson.Int(20),
   714  					btcjson.Int(1), nil)
   715  			},
   716  			marshalled: `{"jsonrpc":"1.0","method":"listtransactions","params":["acct",20,1],"id":1}`,
   717  			unmarshalled: &btcjson.ListTransactionsCmd{
   718  				Account:          btcjson.String("acct"),
   719  				Count:            btcjson.Int(20),
   720  				From:             btcjson.Int(1),
   721  				IncludeWatchOnly: btcjson.Bool(false),
   722  			},
   723  		},
   724  		{
   725  			name: "listtransactions optional4",
   726  			newCmd: func() (interface{}, error) {
   727  				return btcjson.NewCmd("listtransactions", "acct", 20, 1, true)
   728  			},
   729  			staticCmd: func() interface{} {
   730  				return btcjson.NewListTransactionsCmd(btcjson.String("acct"), btcjson.Int(20),
   731  					btcjson.Int(1), btcjson.Bool(true))
   732  			},
   733  			marshalled: `{"jsonrpc":"1.0","method":"listtransactions","params":["acct",20,1,true],"id":1}`,
   734  			unmarshalled: &btcjson.ListTransactionsCmd{
   735  				Account:          btcjson.String("acct"),
   736  				Count:            btcjson.Int(20),
   737  				From:             btcjson.Int(1),
   738  				IncludeWatchOnly: btcjson.Bool(true),
   739  			},
   740  		},
   741  		{
   742  			name: "listunspent",
   743  			newCmd: func() (interface{}, error) {
   744  				return btcjson.NewCmd("listunspent")
   745  			},
   746  			staticCmd: func() interface{} {
   747  				return btcjson.NewListUnspentCmd(nil, nil, nil)
   748  			},
   749  			marshalled: `{"jsonrpc":"1.0","method":"listunspent","params":[],"id":1}`,
   750  			unmarshalled: &btcjson.ListUnspentCmd{
   751  				MinConf:   btcjson.Int(1),
   752  				MaxConf:   btcjson.Int(9999999),
   753  				Addresses: nil,
   754  			},
   755  		},
   756  		{
   757  			name: "listunspent optional1",
   758  			newCmd: func() (interface{}, error) {
   759  				return btcjson.NewCmd("listunspent", 6)
   760  			},
   761  			staticCmd: func() interface{} {
   762  				return btcjson.NewListUnspentCmd(btcjson.Int(6), nil, nil)
   763  			},
   764  			marshalled: `{"jsonrpc":"1.0","method":"listunspent","params":[6],"id":1}`,
   765  			unmarshalled: &btcjson.ListUnspentCmd{
   766  				MinConf:   btcjson.Int(6),
   767  				MaxConf:   btcjson.Int(9999999),
   768  				Addresses: nil,
   769  			},
   770  		},
   771  		{
   772  			name: "listunspent optional2",
   773  			newCmd: func() (interface{}, error) {
   774  				return btcjson.NewCmd("listunspent", 6, 100)
   775  			},
   776  			staticCmd: func() interface{} {
   777  				return btcjson.NewListUnspentCmd(btcjson.Int(6), btcjson.Int(100), nil)
   778  			},
   779  			marshalled: `{"jsonrpc":"1.0","method":"listunspent","params":[6,100],"id":1}`,
   780  			unmarshalled: &btcjson.ListUnspentCmd{
   781  				MinConf:   btcjson.Int(6),
   782  				MaxConf:   btcjson.Int(100),
   783  				Addresses: nil,
   784  			},
   785  		},
   786  		{
   787  			name: "listunspent optional3",
   788  			newCmd: func() (interface{}, error) {
   789  				return btcjson.NewCmd("listunspent", 6, 100, []string{"1Address", "1Address2"})
   790  			},
   791  			staticCmd: func() interface{} {
   792  				return btcjson.NewListUnspentCmd(btcjson.Int(6), btcjson.Int(100),
   793  					&[]string{"1Address", "1Address2"})
   794  			},
   795  			marshalled: `{"jsonrpc":"1.0","method":"listunspent","params":[6,100,["1Address","1Address2"]],"id":1}`,
   796  			unmarshalled: &btcjson.ListUnspentCmd{
   797  				MinConf:   btcjson.Int(6),
   798  				MaxConf:   btcjson.Int(100),
   799  				Addresses: &[]string{"1Address", "1Address2"},
   800  			},
   801  		},
   802  		{
   803  			name: "lockunspent",
   804  			newCmd: func() (interface{}, error) {
   805  				return btcjson.NewCmd("lockunspent", true, `[{"txid":"123","vout":1}]`)
   806  			},
   807  			staticCmd: func() interface{} {
   808  				txInputs := []btcjson.TransactionInput{
   809  					{Txid: "123", Vout: 1},
   810  				}
   811  				return btcjson.NewLockUnspentCmd(true, txInputs)
   812  			},
   813  			marshalled: `{"jsonrpc":"1.0","method":"lockunspent","params":[true,[{"txid":"123","vout":1}]],"id":1}`,
   814  			unmarshalled: &btcjson.LockUnspentCmd{
   815  				Unlock: true,
   816  				Transactions: []btcjson.TransactionInput{
   817  					{Txid: "123", Vout: 1},
   818  				},
   819  			},
   820  		},
   821  		{
   822  			name: "move",
   823  			newCmd: func() (interface{}, error) {
   824  				return btcjson.NewCmd("move", "from", "to", 0.5)
   825  			},
   826  			staticCmd: func() interface{} {
   827  				return btcjson.NewMoveCmd("from", "to", 0.5, nil, nil)
   828  			},
   829  			marshalled: `{"jsonrpc":"1.0","method":"move","params":["from","to",0.5],"id":1}`,
   830  			unmarshalled: &btcjson.MoveCmd{
   831  				FromAccount: "from",
   832  				ToAccount:   "to",
   833  				Amount:      0.5,
   834  				MinConf:     btcjson.Int(1),
   835  				Comment:     nil,
   836  			},
   837  		},
   838  		{
   839  			name: "move optional1",
   840  			newCmd: func() (interface{}, error) {
   841  				return btcjson.NewCmd("move", "from", "to", 0.5, 6)
   842  			},
   843  			staticCmd: func() interface{} {
   844  				return btcjson.NewMoveCmd("from", "to", 0.5, btcjson.Int(6), nil)
   845  			},
   846  			marshalled: `{"jsonrpc":"1.0","method":"move","params":["from","to",0.5,6],"id":1}`,
   847  			unmarshalled: &btcjson.MoveCmd{
   848  				FromAccount: "from",
   849  				ToAccount:   "to",
   850  				Amount:      0.5,
   851  				MinConf:     btcjson.Int(6),
   852  				Comment:     nil,
   853  			},
   854  		},
   855  		{
   856  			name: "move optional2",
   857  			newCmd: func() (interface{}, error) {
   858  				return btcjson.NewCmd("move", "from", "to", 0.5, 6, "comment")
   859  			},
   860  			staticCmd: func() interface{} {
   861  				return btcjson.NewMoveCmd("from", "to", 0.5, btcjson.Int(6), btcjson.String("comment"))
   862  			},
   863  			marshalled: `{"jsonrpc":"1.0","method":"move","params":["from","to",0.5,6,"comment"],"id":1}`,
   864  			unmarshalled: &btcjson.MoveCmd{
   865  				FromAccount: "from",
   866  				ToAccount:   "to",
   867  				Amount:      0.5,
   868  				MinConf:     btcjson.Int(6),
   869  				Comment:     btcjson.String("comment"),
   870  			},
   871  		},
   872  		{
   873  			name: "sendfrom",
   874  			newCmd: func() (interface{}, error) {
   875  				return btcjson.NewCmd("sendfrom", "from", "1Address", 0.5)
   876  			},
   877  			staticCmd: func() interface{} {
   878  				return btcjson.NewSendFromCmd("from", "1Address", 0.5, nil, nil, nil)
   879  			},
   880  			marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address",0.5],"id":1}`,
   881  			unmarshalled: &btcjson.SendFromCmd{
   882  				FromAccount: "from",
   883  				ToAddress:   "1Address",
   884  				Amount:      0.5,
   885  				MinConf:     btcjson.Int(1),
   886  				Comment:     nil,
   887  				CommentTo:   nil,
   888  			},
   889  		},
   890  		{
   891  			name: "sendfrom optional1",
   892  			newCmd: func() (interface{}, error) {
   893  				return btcjson.NewCmd("sendfrom", "from", "1Address", 0.5, 6)
   894  			},
   895  			staticCmd: func() interface{} {
   896  				return btcjson.NewSendFromCmd("from", "1Address", 0.5, btcjson.Int(6), nil, nil)
   897  			},
   898  			marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address",0.5,6],"id":1}`,
   899  			unmarshalled: &btcjson.SendFromCmd{
   900  				FromAccount: "from",
   901  				ToAddress:   "1Address",
   902  				Amount:      0.5,
   903  				MinConf:     btcjson.Int(6),
   904  				Comment:     nil,
   905  				CommentTo:   nil,
   906  			},
   907  		},
   908  		{
   909  			name: "sendfrom optional2",
   910  			newCmd: func() (interface{}, error) {
   911  				return btcjson.NewCmd("sendfrom", "from", "1Address", 0.5, 6, "comment")
   912  			},
   913  			staticCmd: func() interface{} {
   914  				return btcjson.NewSendFromCmd("from", "1Address", 0.5, btcjson.Int(6),
   915  					btcjson.String("comment"), nil)
   916  			},
   917  			marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address",0.5,6,"comment"],"id":1}`,
   918  			unmarshalled: &btcjson.SendFromCmd{
   919  				FromAccount: "from",
   920  				ToAddress:   "1Address",
   921  				Amount:      0.5,
   922  				MinConf:     btcjson.Int(6),
   923  				Comment:     btcjson.String("comment"),
   924  				CommentTo:   nil,
   925  			},
   926  		},
   927  		{
   928  			name: "sendfrom optional3",
   929  			newCmd: func() (interface{}, error) {
   930  				return btcjson.NewCmd("sendfrom", "from", "1Address", 0.5, 6, "comment", "commentto")
   931  			},
   932  			staticCmd: func() interface{} {
   933  				return btcjson.NewSendFromCmd("from", "1Address", 0.5, btcjson.Int(6),
   934  					btcjson.String("comment"), btcjson.String("commentto"))
   935  			},
   936  			marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address",0.5,6,"comment","commentto"],"id":1}`,
   937  			unmarshalled: &btcjson.SendFromCmd{
   938  				FromAccount: "from",
   939  				ToAddress:   "1Address",
   940  				Amount:      0.5,
   941  				MinConf:     btcjson.Int(6),
   942  				Comment:     btcjson.String("comment"),
   943  				CommentTo:   btcjson.String("commentto"),
   944  			},
   945  		},
   946  		{
   947  			name: "sendmany",
   948  			newCmd: func() (interface{}, error) {
   949  				return btcjson.NewCmd("sendmany", "from", `{"1Address":0.5}`)
   950  			},
   951  			staticCmd: func() interface{} {
   952  				amounts := map[string]float64{"1Address": 0.5}
   953  				return btcjson.NewSendManyCmd("from", amounts, nil, nil)
   954  			},
   955  			marshalled: `{"jsonrpc":"1.0","method":"sendmany","params":["from",{"1Address":0.5}],"id":1}`,
   956  			unmarshalled: &btcjson.SendManyCmd{
   957  				FromAccount: "from",
   958  				Amounts:     map[string]float64{"1Address": 0.5},
   959  				MinConf:     btcjson.Int(1),
   960  				Comment:     nil,
   961  			},
   962  		},
   963  		{
   964  			name: "sendmany optional1",
   965  			newCmd: func() (interface{}, error) {
   966  				return btcjson.NewCmd("sendmany", "from", `{"1Address":0.5}`, 6)
   967  			},
   968  			staticCmd: func() interface{} {
   969  				amounts := map[string]float64{"1Address": 0.5}
   970  				return btcjson.NewSendManyCmd("from", amounts, btcjson.Int(6), nil)
   971  			},
   972  			marshalled: `{"jsonrpc":"1.0","method":"sendmany","params":["from",{"1Address":0.5},6],"id":1}`,
   973  			unmarshalled: &btcjson.SendManyCmd{
   974  				FromAccount: "from",
   975  				Amounts:     map[string]float64{"1Address": 0.5},
   976  				MinConf:     btcjson.Int(6),
   977  				Comment:     nil,
   978  			},
   979  		},
   980  		{
   981  			name: "sendmany optional2",
   982  			newCmd: func() (interface{}, error) {
   983  				return btcjson.NewCmd("sendmany", "from", `{"1Address":0.5}`, 6, "comment")
   984  			},
   985  			staticCmd: func() interface{} {
   986  				amounts := map[string]float64{"1Address": 0.5}
   987  				return btcjson.NewSendManyCmd("from", amounts, btcjson.Int(6), btcjson.String("comment"))
   988  			},
   989  			marshalled: `{"jsonrpc":"1.0","method":"sendmany","params":["from",{"1Address":0.5},6,"comment"],"id":1}`,
   990  			unmarshalled: &btcjson.SendManyCmd{
   991  				FromAccount: "from",
   992  				Amounts:     map[string]float64{"1Address": 0.5},
   993  				MinConf:     btcjson.Int(6),
   994  				Comment:     btcjson.String("comment"),
   995  			},
   996  		},
   997  		{
   998  			name: "sendtoaddress",
   999  			newCmd: func() (interface{}, error) {
  1000  				return btcjson.NewCmd("sendtoaddress", "1Address", 0.5)
  1001  			},
  1002  			staticCmd: func() interface{} {
  1003  				return btcjson.NewSendToAddressCmd("1Address", 0.5, nil, nil)
  1004  			},
  1005  			marshalled: `{"jsonrpc":"1.0","method":"sendtoaddress","params":["1Address",0.5],"id":1}`,
  1006  			unmarshalled: &btcjson.SendToAddressCmd{
  1007  				Address:   "1Address",
  1008  				Amount:    0.5,
  1009  				Comment:   nil,
  1010  				CommentTo: nil,
  1011  			},
  1012  		},
  1013  		{
  1014  			name: "sendtoaddress optional1",
  1015  			newCmd: func() (interface{}, error) {
  1016  				return btcjson.NewCmd("sendtoaddress", "1Address", 0.5, "comment", "commentto")
  1017  			},
  1018  			staticCmd: func() interface{} {
  1019  				return btcjson.NewSendToAddressCmd("1Address", 0.5, btcjson.String("comment"),
  1020  					btcjson.String("commentto"))
  1021  			},
  1022  			marshalled: `{"jsonrpc":"1.0","method":"sendtoaddress","params":["1Address",0.5,"comment","commentto"],"id":1}`,
  1023  			unmarshalled: &btcjson.SendToAddressCmd{
  1024  				Address:   "1Address",
  1025  				Amount:    0.5,
  1026  				Comment:   btcjson.String("comment"),
  1027  				CommentTo: btcjson.String("commentto"),
  1028  			},
  1029  		},
  1030  		{
  1031  			name: "setaccount",
  1032  			newCmd: func() (interface{}, error) {
  1033  				return btcjson.NewCmd("setaccount", "1Address", "acct")
  1034  			},
  1035  			staticCmd: func() interface{} {
  1036  				return btcjson.NewSetAccountCmd("1Address", "acct")
  1037  			},
  1038  			marshalled: `{"jsonrpc":"1.0","method":"setaccount","params":["1Address","acct"],"id":1}`,
  1039  			unmarshalled: &btcjson.SetAccountCmd{
  1040  				Address: "1Address",
  1041  				Account: "acct",
  1042  			},
  1043  		},
  1044  		{
  1045  			name: "settxfee",
  1046  			newCmd: func() (interface{}, error) {
  1047  				return btcjson.NewCmd("settxfee", 0.0001)
  1048  			},
  1049  			staticCmd: func() interface{} {
  1050  				return btcjson.NewSetTxFeeCmd(0.0001)
  1051  			},
  1052  			marshalled: `{"jsonrpc":"1.0","method":"settxfee","params":[0.0001],"id":1}`,
  1053  			unmarshalled: &btcjson.SetTxFeeCmd{
  1054  				Amount: 0.0001,
  1055  			},
  1056  		},
  1057  		{
  1058  			name: "signmessage",
  1059  			newCmd: func() (interface{}, error) {
  1060  				return btcjson.NewCmd("signmessage", "1Address", "message")
  1061  			},
  1062  			staticCmd: func() interface{} {
  1063  				return btcjson.NewSignMessageCmd("1Address", "message")
  1064  			},
  1065  			marshalled: `{"jsonrpc":"1.0","method":"signmessage","params":["1Address","message"],"id":1}`,
  1066  			unmarshalled: &btcjson.SignMessageCmd{
  1067  				Address: "1Address",
  1068  				Message: "message",
  1069  			},
  1070  		},
  1071  		{
  1072  			name: "signrawtransaction",
  1073  			newCmd: func() (interface{}, error) {
  1074  				return btcjson.NewCmd("signrawtransaction", "001122")
  1075  			},
  1076  			staticCmd: func() interface{} {
  1077  				return btcjson.NewSignRawTransactionCmd("001122", nil, nil, nil)
  1078  			},
  1079  			marshalled: `{"jsonrpc":"1.0","method":"signrawtransaction","params":["001122"],"id":1}`,
  1080  			unmarshalled: &btcjson.SignRawTransactionCmd{
  1081  				RawTx:    "001122",
  1082  				Inputs:   nil,
  1083  				PrivKeys: nil,
  1084  				Flags:    btcjson.String("ALL"),
  1085  			},
  1086  		},
  1087  		{
  1088  			name: "signrawtransaction optional1",
  1089  			newCmd: func() (interface{}, error) {
  1090  				return btcjson.NewCmd("signrawtransaction", "001122", `[{"txid":"123","vout":1,"scriptPubKey":"00","redeemScript":"01"}]`)
  1091  			},
  1092  			staticCmd: func() interface{} {
  1093  				txInputs := []btcjson.RawTxInput{
  1094  					{
  1095  						Txid:         "123",
  1096  						Vout:         1,
  1097  						ScriptPubKey: "00",
  1098  						RedeemScript: "01",
  1099  					},
  1100  				}
  1101  
  1102  				return btcjson.NewSignRawTransactionCmd("001122", &txInputs, nil, nil)
  1103  			},
  1104  			marshalled: `{"jsonrpc":"1.0","method":"signrawtransaction","params":["001122",[{"txid":"123","vout":1,"scriptPubKey":"00","redeemScript":"01"}]],"id":1}`,
  1105  			unmarshalled: &btcjson.SignRawTransactionCmd{
  1106  				RawTx: "001122",
  1107  				Inputs: &[]btcjson.RawTxInput{
  1108  					{
  1109  						Txid:         "123",
  1110  						Vout:         1,
  1111  						ScriptPubKey: "00",
  1112  						RedeemScript: "01",
  1113  					},
  1114  				},
  1115  				PrivKeys: nil,
  1116  				Flags:    btcjson.String("ALL"),
  1117  			},
  1118  		},
  1119  		{
  1120  			name: "signrawtransaction optional2",
  1121  			newCmd: func() (interface{}, error) {
  1122  				return btcjson.NewCmd("signrawtransaction", "001122", `[]`, `["abc"]`)
  1123  			},
  1124  			staticCmd: func() interface{} {
  1125  				txInputs := []btcjson.RawTxInput{}
  1126  				privKeys := []string{"abc"}
  1127  				return btcjson.NewSignRawTransactionCmd("001122", &txInputs, &privKeys, nil)
  1128  			},
  1129  			marshalled: `{"jsonrpc":"1.0","method":"signrawtransaction","params":["001122",[],["abc"]],"id":1}`,
  1130  			unmarshalled: &btcjson.SignRawTransactionCmd{
  1131  				RawTx:    "001122",
  1132  				Inputs:   &[]btcjson.RawTxInput{},
  1133  				PrivKeys: &[]string{"abc"},
  1134  				Flags:    btcjson.String("ALL"),
  1135  			},
  1136  		},
  1137  		{
  1138  			name: "signrawtransaction optional3",
  1139  			newCmd: func() (interface{}, error) {
  1140  				return btcjson.NewCmd("signrawtransaction", "001122", `[]`, `[]`, "ALL")
  1141  			},
  1142  			staticCmd: func() interface{} {
  1143  				txInputs := []btcjson.RawTxInput{}
  1144  				privKeys := []string{}
  1145  				return btcjson.NewSignRawTransactionCmd("001122", &txInputs, &privKeys,
  1146  					btcjson.String("ALL"))
  1147  			},
  1148  			marshalled: `{"jsonrpc":"1.0","method":"signrawtransaction","params":["001122",[],[],"ALL"],"id":1}`,
  1149  			unmarshalled: &btcjson.SignRawTransactionCmd{
  1150  				RawTx:    "001122",
  1151  				Inputs:   &[]btcjson.RawTxInput{},
  1152  				PrivKeys: &[]string{},
  1153  				Flags:    btcjson.String("ALL"),
  1154  			},
  1155  		},
  1156  		{
  1157  			name: "walletlock",
  1158  			newCmd: func() (interface{}, error) {
  1159  				return btcjson.NewCmd("walletlock")
  1160  			},
  1161  			staticCmd: func() interface{} {
  1162  				return btcjson.NewWalletLockCmd()
  1163  			},
  1164  			marshalled:   `{"jsonrpc":"1.0","method":"walletlock","params":[],"id":1}`,
  1165  			unmarshalled: &btcjson.WalletLockCmd{},
  1166  		},
  1167  		{
  1168  			name: "walletpassphrase",
  1169  			newCmd: func() (interface{}, error) {
  1170  				return btcjson.NewCmd("walletpassphrase", "pass", 60)
  1171  			},
  1172  			staticCmd: func() interface{} {
  1173  				return btcjson.NewWalletPassphraseCmd("pass", 60)
  1174  			},
  1175  			marshalled: `{"jsonrpc":"1.0","method":"walletpassphrase","params":["pass",60],"id":1}`,
  1176  			unmarshalled: &btcjson.WalletPassphraseCmd{
  1177  				Passphrase: "pass",
  1178  				Timeout:    60,
  1179  			},
  1180  		},
  1181  		{
  1182  			name: "walletpassphrasechange",
  1183  			newCmd: func() (interface{}, error) {
  1184  				return btcjson.NewCmd("walletpassphrasechange", "old", "new")
  1185  			},
  1186  			staticCmd: func() interface{} {
  1187  				return btcjson.NewWalletPassphraseChangeCmd("old", "new")
  1188  			},
  1189  			marshalled: `{"jsonrpc":"1.0","method":"walletpassphrasechange","params":["old","new"],"id":1}`,
  1190  			unmarshalled: &btcjson.WalletPassphraseChangeCmd{
  1191  				OldPassphrase: "old",
  1192  				NewPassphrase: "new",
  1193  			},
  1194  		},
  1195  	}
  1196  
  1197  	t.Logf("Running %d tests", len(tests))
  1198  	for i, test := range tests {
  1199  		// Marshal the command as created by the new static command
  1200  		// creation function.
  1201  		marshalled, err := btcjson.MarshalCmd(testID, test.staticCmd())
  1202  		if err != nil {
  1203  			t.Errorf("MarshalCmd #%d (%s) unexpected error: %v", i,
  1204  				test.name, err)
  1205  			continue
  1206  		}
  1207  
  1208  		if !bytes.Equal(marshalled, []byte(test.marshalled)) {
  1209  			t.Errorf("Test #%d (%s) unexpected marshalled data - "+
  1210  				"got %s, want %s", i, test.name, marshalled,
  1211  				test.marshalled)
  1212  			continue
  1213  		}
  1214  
  1215  		// Ensure the command is created without error via the generic
  1216  		// new command creation function.
  1217  		cmd, err := test.newCmd()
  1218  		if err != nil {
  1219  			t.Errorf("Test #%d (%s) unexpected NewCmd error: %v ",
  1220  				i, test.name, err)
  1221  		}
  1222  
  1223  		// Marshal the command as created by the generic new command
  1224  		// creation function.
  1225  		marshalled, err = btcjson.MarshalCmd(testID, cmd)
  1226  		if err != nil {
  1227  			t.Errorf("MarshalCmd #%d (%s) unexpected error: %v", i,
  1228  				test.name, err)
  1229  			continue
  1230  		}
  1231  
  1232  		if !bytes.Equal(marshalled, []byte(test.marshalled)) {
  1233  			t.Errorf("Test #%d (%s) unexpected marshalled data - "+
  1234  				"got %s, want %s", i, test.name, marshalled,
  1235  				test.marshalled)
  1236  			continue
  1237  		}
  1238  
  1239  		var request btcjson.Request
  1240  		if err := json.Unmarshal(marshalled, &request); err != nil {
  1241  			t.Errorf("Test #%d (%s) unexpected error while "+
  1242  				"unmarshalling JSON-RPC request: %v", i,
  1243  				test.name, err)
  1244  			continue
  1245  		}
  1246  
  1247  		cmd, err = btcjson.UnmarshalCmd(&request)
  1248  		if err != nil {
  1249  			t.Errorf("UnmarshalCmd #%d (%s) unexpected error: %v", i,
  1250  				test.name, err)
  1251  			continue
  1252  		}
  1253  
  1254  		if !reflect.DeepEqual(cmd, test.unmarshalled) {
  1255  			t.Errorf("Test #%d (%s) unexpected unmarshalled command "+
  1256  				"- got %s, want %s", i, test.name,
  1257  				fmt.Sprintf("(%T) %+[1]v", cmd),
  1258  				fmt.Sprintf("(%T) %+[1]v\n", test.unmarshalled))
  1259  			continue
  1260  		}
  1261  	}
  1262  }