btcjson: Implement addwitnessaddress functionality.

This commit is contained in:
Craig Sturdy 2017-09-11 05:10:46 +01:00 committed by Dave Collins
parent 63d1550d42
commit 91e5ba1a80
2 changed files with 27 additions and 0 deletions

View file

@ -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. // CreateMultisigCmd defines the createmultisig JSON-RPC command.
type CreateMultisigCmd struct { type CreateMultisigCmd struct {
NRequired int NRequired int
@ -645,6 +658,7 @@ func init() {
flags := UFWalletOnly flags := UFWalletOnly
MustRegisterCmd("addmultisigaddress", (*AddMultisigAddressCmd)(nil), flags) MustRegisterCmd("addmultisigaddress", (*AddMultisigAddressCmd)(nil), flags)
MustRegisterCmd("addwitnessaddress", (*AddWitnessAddressCmd)(nil), flags)
MustRegisterCmd("createmultisig", (*CreateMultisigCmd)(nil), flags) MustRegisterCmd("createmultisig", (*CreateMultisigCmd)(nil), flags)
MustRegisterCmd("dumpprivkey", (*DumpPrivKeyCmd)(nil), flags) MustRegisterCmd("dumpprivkey", (*DumpPrivKeyCmd)(nil), flags)
MustRegisterCmd("encryptwallet", (*EncryptWalletCmd)(nil), flags) MustRegisterCmd("encryptwallet", (*EncryptWalletCmd)(nil), flags)

View file

@ -61,6 +61,19 @@ func TestWalletSvrCmds(t *testing.T) {
Account: btcjson.String("test"), 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", name: "createmultisig",
newCmd: func() (interface{}, error) { newCmd: func() (interface{}, error) {