コード例 #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)
	}
}
コード例 #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)
	}
}