Ejemplo n.º 1
0
// Returns either an unbounded list of transactions, or the list of
// transactions that involve a given address.
//
func HandleGetProcessedTransactions(ctx *web.Context, parms string) {
	cmd := ctx.Params["cmd"]
	adr := ctx.Params["address"]

	if cmd == "all" {
		list, err := Utility.DumpTransactions(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.DumpTransactions(adrs)
		if err != nil {
			reportResults(ctx, err.Error(), false)
			return
		}
		reportResults(ctx, string(list), true)
	}
}
Ejemplo n.º 2
0
// List transactions <address list>
func (List) 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.DumpTransactions(nil); 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.DumpTransactions(addresses); err != nil {
			return err
		}
		fmt.Print(string(list))
	}
	return nil
}