From 91e5ba1a80082d436cc35965d74e0a41be7f2d99 Mon Sep 17 00:00:00 2001 From: Craig Sturdy Date: Mon, 11 Sep 2017 05:10:46 +0100 Subject: [PATCH] btcjson: Implement addwitnessaddress functionality. --- btcjson/walletsvrcmds.go | 14 ++++++++++++++ btcjson/walletsvrcmds_test.go | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/btcjson/walletsvrcmds.go b/btcjson/walletsvrcmds.go index f340714b..66975551 100644 --- a/btcjson/walletsvrcmds.go +++ b/btcjson/walletsvrcmds.go @@ -27,6 +27,19 @@ func NewAddMultisigAddressCmd(nRequired int, keys []string, account *string) *Ad } } +// AddWitnessAddressCmd defines the addwitnessaddress JSON-RPC command. +type AddWitnessAddressCmd struct { + Address string +} + +// NewAddWitnessAddressCmd returns a new instance which can be used to issue a +// addwitnessaddress JSON-RPC command. +func NewAddWitnessAddressCmd(address string) *AddWitnessAddressCmd { + return &AddWitnessAddressCmd{ + Address: address, + } +} + // CreateMultisigCmd defines the createmultisig JSON-RPC command. type CreateMultisigCmd struct { NRequired int @@ -645,6 +658,7 @@ func init() { flags := UFWalletOnly MustRegisterCmd("addmultisigaddress", (*AddMultisigAddressCmd)(nil), flags) + MustRegisterCmd("addwitnessaddress", (*AddWitnessAddressCmd)(nil), flags) MustRegisterCmd("createmultisig", (*CreateMultisigCmd)(nil), flags) MustRegisterCmd("dumpprivkey", (*DumpPrivKeyCmd)(nil), flags) MustRegisterCmd("encryptwallet", (*EncryptWalletCmd)(nil), flags) diff --git a/btcjson/walletsvrcmds_test.go b/btcjson/walletsvrcmds_test.go index d4755cc1..efc08cc9 100644 --- a/btcjson/walletsvrcmds_test.go +++ b/btcjson/walletsvrcmds_test.go @@ -61,6 +61,19 @@ func TestWalletSvrCmds(t *testing.T) { Account: btcjson.String("test"), }, }, + { + name: "addwitnessaddress", + newCmd: func() (interface{}, error) { + return btcjson.NewCmd("addwitnessaddress", "1address") + }, + staticCmd: func() interface{} { + return btcjson.NewAddWitnessAddressCmd("1address") + }, + marshalled: `{"jsonrpc":"1.0","method":"addwitnessaddress","params":["1address"],"id":1}`, + unmarshalled: &btcjson.AddWitnessAddressCmd{ + Address: "1address", + }, + }, { name: "createmultisig", newCmd: func() (interface{}, error) {