Example #1
0
// Returns either an unbounded list of transactions, or the list of
// transactions that involve a given address.
//
// Return in JSON
//
func HandleGetProcessedTransactionsj(ctx *web.Context, parms string) {
	cmd := ctx.Params["cmd"]
	adr := ctx.Params["address"]

	if cmd == "all" {
		list, err := Utility.DumpTransactionsJSON(nil)
		if err != nil {
			reportResults(ctx, err.Error(), false)
			return
		}
		reportResults(ctx, string(list), true)
	} else {

		adr, err := Wallet.LookupAddress("FA", adr)
		if err != nil {
			adr, err = Wallet.LookupAddress("EC", adr)
			if err != nil {
				reportResults(ctx, fmt.Sprintf("Could not understand address %s", adr), false)
				return
			}
		}
		badr, err := hex.DecodeString(adr)

		var adrs [][]byte
		adrs = append(adrs, badr)

		list, err := Utility.DumpTransactionsJSON(adrs)
		if err != nil {
			reportResults(ctx, err.Error(), false)
			return
		}
		reportResults(ctx, string(list), true)
	}
}
Example #2
0
// Returns either an unbounded list of transactions, or the list of
// transactions that involve a given address.
//
// Return in JSON
//
func HandleGetProcessedTransactionsj(ctx *web.Context, parms string) {
	cmd := ctx.Params["cmd"]
	adr := ctx.Params["address"]
	sstart := ctx.Params["start"]
	send := ctx.Params["end"]

	if len(sstart) == 0 {
		sstart = "0"
	}
	if len(send) == 0 {
		send = "0"
	}

	start, err1 := strconv.ParseInt(sstart, 10, 32)
	end, err2 := strconv.ParseInt(send, 10, 32)
	if err1 != nil || err2 != nil {
		start = 0
		end = 1000000000
	}

	if cmd == "all" {
		list, err := Utility.DumpTransactionsJSON(nil, int(start), int(end))
		if err != nil {
			reportResults(ctx, err.Error(), false)
			return
		}
		reportResults(ctx, string(list), true)
	} else {

		adr, err := Wallet.LookupAddress("FA", adr)
		if err != nil {
			adr, err = Wallet.LookupAddress("EC", adr)
			if err != nil {
				reportResults(ctx, fmt.Sprintf("Could not understand address %s", adr), false)
				return
			}
		}
		badr, err := hex.DecodeString(adr)

		var adrs [][]byte
		adrs = append(adrs, badr)

		list, err := Utility.DumpTransactionsJSON(adrs, int(start), int(end))
		if err != nil {
			reportResults(ctx, err.Error(), false)
			return
		}
		reportResults(ctx, string(list), true)
	}
}
Example #3
0
// List transactions <address list>
func (Listj) Execute(state IState, args []string) (err error) {
	if len(args) <= 1 {
		return fmt.Errorf("Nothing to list")
	}
	switch args[1] {
	case "all":
		fmt.Println("Listing all transactions: ")
		var list []byte
		if list, err = Utility.DumpTransactionsJSON(nil, 0, 0); err != nil {
			return err
		}
		fmt.Print(string(list))
		break
	default:
		var addresses [][]byte
		var adr string
		for i := 1; i < len(args); i++ {
			adr, err = LookupAddress(state, "FA", args[i])
			if err != nil {
				adr, err = LookupAddress(state, "EC", args[i])
				if err != nil {
					return fmt.Errorf("Could not understand address %s", args[i])
				}
			}
			badr, err := hex.DecodeString(adr)
			if err != nil {
				return fmt.Errorf("Could not understand address %s", args[i])
			}
			addresses = append(addresses, badr)
		}
		var list []byte
		if list, err = Utility.DumpTransactionsJSON(addresses, 0, 0); err != nil {
			return err
		}
		fmt.Print(string(list))
	}
	return nil
}