示例#1
0
文件: cmds.go 项目: 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)
}
示例#2
0
文件: cmds.go 项目: 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)
}
示例#3
0
文件: cmds.go 项目: 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)
}
示例#4
0
文件: cmds.go 项目: 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)
}
示例#5
0
文件: cmds.go 项目: 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)
}
示例#6
0
文件: cmds.go 项目: 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)
}