Function: mail-check-payment

mail-check-payment is an autoloaded, interactive and byte-compiled function defined in hashcash.el.gz.

Signature

(mail-check-payment &optional ARG)

Documentation

Look for a valid X-Payment: or X-Hashcash: header.

Prefix arg sets default accept amount temporarily.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mail/hashcash.el.gz
;;;###autoload
(defun mail-check-payment (&optional arg)
  "Look for a valid X-Payment: or X-Hashcash: header.
Prefix arg sets default accept amount temporarily."
  (interactive "P")
  (let ((hashcash-default-accept-payment (if arg (prefix-numeric-value arg)
					   hashcash-default-accept-payment))
	(version (hashcash-version (hashcash-generate-payment "x" 1))))
    (save-excursion
      (goto-char (point-min))
      (search-forward "\n\n")
      (beginning-of-line)
      (let ((end (point))
	    (ok nil))
	(goto-char (point-min))
	(while (and (not ok) (search-forward "X-Payment: hashcash " end t))
	  (let ((value (split-string (hashcash-token-substring) " ")))
	    (when (equal (car value) (number-to-string version))
	      (setq ok (hashcash-verify-payment (cadr value))))))
	(goto-char (point-min))
	(while (and (not ok) (search-forward "X-Hashcash: " end t))
	  (setq ok (hashcash-verify-payment (hashcash-token-substring))))
	(when ok
	  (message "Payment valid"))
	ok))))