Exemplo n.º 1
0
Arquivo: cmds.go Projeto: hsk81/btcws
// MarshalJSON returns the JSON encoding of cmd.  Part of the Cmd interface.
func (cmd *GetUnconfirmedBalanceCmd) MarshalJSON() ([]byte, error) {
	// Fill a RawCmd and marshal.
	raw := btcjson.RawCmd{
		Jsonrpc: "1.0",
		Method:  "getunconfirmedbalance",
		Id:      cmd.id,
	}

	if cmd.Account != "" {
		raw.Params = append(raw.Params, cmd.Account)
	}

	return json.Marshal(raw)
}
Exemplo n.º 2
0
Arquivo: cmds.go Projeto: hsk81/btcws
// MarshalJSON returns the JSON encoding of cmd.  Part of the Cmd interface.
func (cmd *ListAllTransactionsCmd) MarshalJSON() ([]byte, error) {
	// Fill a RawCmd and marshal.
	raw := btcjson.RawCmd{
		Jsonrpc: "1.0",
		Method:  "listalltransactions",
		Id:      cmd.id,
		Params:  []interface{}{},
	}

	if cmd.Account != "" {
		raw.Params = append(raw.Params, cmd.Account)
	}

	return json.Marshal(raw)
}
Exemplo n.º 3
0
Arquivo: cmds.go Projeto: hsk81/btcws
// MarshalJSON returns the JSON encoding of cmd.  Part of the Cmd interface.
func (cmd *WalletIsLockedCmd) MarshalJSON() ([]byte, error) {
	// Fill a RawCmd and marshal.
	raw := btcjson.RawCmd{
		Jsonrpc: "1.0",
		Method:  "walletislocked",
		Id:      cmd.id,
		Params:  []interface{}{},
	}

	if cmd.Account != "" {
		raw.Params = append(raw.Params, cmd.Account)
	}

	return json.Marshal(raw)
}
Exemplo n.º 4
0
Arquivo: cmds.go Projeto: hsk81/btcws
// MarshalJSON returns the JSON encoding of cmd.  Part of the Cmd interface.
func (cmd *ExportWatchingWalletCmd) MarshalJSON() ([]byte, error) {
	// Fill a RawCmd and marshal.
	raw := btcjson.RawCmd{
		Jsonrpc: "1.0",
		Method:  "exportwatchingwallet",
		Id:      cmd.id,
	}

	if cmd.Account != "" || cmd.Download {
		raw.Params = append(raw.Params, cmd.Account)
	}
	if cmd.Download {
		raw.Params = append(raw.Params, cmd.Download)
	}

	return json.Marshal(raw)
}
Exemplo n.º 5
0
Arquivo: cmds.go Projeto: hsk81/btcws
// MarshalJSON returns the JSON encoding of cmd.  Part of the Cmd interface.
func (cmd *GetAddressBalanceCmd) MarshalJSON() ([]byte, error) {
	// Fill a RawCmd and marshal.
	raw := btcjson.RawCmd{
		Jsonrpc: "1.0",
		Method:  "getaddressbalance",
		Id:      cmd.id,
		Params: []interface{}{
			cmd.Address,
		},
	}

	if cmd.Minconf != 1 {
		raw.Params = append(raw.Params, cmd.Minconf)
	}

	return json.Marshal(raw)
}
Exemplo n.º 6
0
Arquivo: cmds.go Projeto: hsk81/btcws
// MarshalJSON returns the JSON encoding of cmd.  Part of the Cmd interface.
func (cmd *RescanCmd) MarshalJSON() ([]byte, error) {
	// Fill a RawCmd and marshal.
	raw := btcjson.RawCmd{
		Jsonrpc: "1.0",
		Method:  "rescan",
		Id:      cmd.id,
		Params: []interface{}{
			cmd.BeginBlock,
			cmd.Addresses,
		},
	}

	if cmd.EndBlock != btcdb.AllShas {
		raw.Params = append(raw.Params, cmd.EndBlock)
	}

	return json.Marshal(raw)
}