WebLN, the interface that a wallet gives a web page: payments from the wallet of the listener, in a browser.
A browser extension or a wallet app puts its provider at window.webln. The page asks for the use of the provider, and the wallet asks the listener. Then the wallet asks the listener again for each payment, unless the listener gave the page a budget.
The functions that call the provider are in ClojureScript only, and each gives a promise of its result, or of a map with a diagnostic under :error.
No standards body defines WebLN. The guide at webln.guide defines its methods, and doc/services.md tells when podcast-clj read it.
WebLN, the interface that a wallet gives a web page: payments from the wallet of the listener, in a browser. A browser extension or a wallet app puts its provider at window.webln. The page asks for the use of the provider, and the wallet asks the listener. Then the wallet asks the listener again for each payment, unless the listener gave the page a budget. The functions that call the provider are in ClojureScript only, and each gives a promise of its result, or of a map with a diagnostic under :error. No standards body defines WebLN. The guide at webln.guide defines its methods, and doc/services.md tells when podcast-clj read it.
(enable!)(enable! opts)Ask the listener for the use of the WebLN provider, with opts, and
give a promise of a map with :enabled? true.
For a page without a provider, the :error is :value/no-provider, and
when the listener says no, it's :value/wallet-refused. The :provider
of opts replaces that of the page. The other functions ask too, so
call this only to know the answer early.
Ask the listener for the use of the WebLN provider, with `opts`, and give a promise of a map with :enabled? true. For a page without a provider, the :error is :value/no-provider, and when the listener says no, it's :value/wallet-refused. The :provider of `opts` replaces that of the page. The other functions ask too, so call this only to know the answer early.
(get-info!)(get-info! opts)Ask the wallet of the listener about itself with opts, and give a
promise of a map of its :alias, :public-key and :methods, as far as
the wallet gives them, or of a map with a diagnostic under :error.
The :methods are the methods of WebLN that the wallet has, such as
keysend. The opts are those of enable!.
Ask the wallet of the listener about itself with `opts`, and give a promise of a map of its :alias, :public-key and :methods, as far as the wallet gives them, or of a map with a diagnostic under :error. The :methods are the methods of WebLN that the wallet has, such as keysend. The `opts` are those of enable!.
(keysend-args payment {:keys [address] :as recipient})The arguments of webln.keysend for payment to recipient, as a map
with the string keys of WebLN, or nil for a recipient that isn't a node
or a payment below 1 sat.
{"destination" "03…"
"amount" "50"
"customRecords" {"7629169" "{\"action\":\"boost\",…}"
"696969" "22"}}
The payment is the map of dk.simongray.podcast.value, and the recipient is a recipient of a value block, of the type node. WebLN counts in whole sats, so the amount is the whole sats of the payment, and the bLIP-10 record tells that amount. The custom records are those of the payment, as text. The report of the arguments says when they leave out the custom key or value of the recipient. Don't send the payment then.
The arguments of webln.keysend for `payment` to `recipient`, as a map
with the string keys of WebLN, or nil for a recipient that isn't a node
or a payment below 1 sat.
{"destination" "03…"
"amount" "50"
"customRecords" {"7629169" "{\"action\":\"boost\",…}"
"696969" "22"}}
The payment is the map of dk.simongray.podcast.value, and the recipient
is a recipient of a value block, of the type node. WebLN counts in whole
sats, so the amount is the whole sats of the payment, and the bLIP-10
record tells that amount. The custom records are those of the payment,
as text. The report of the arguments says when they leave out the
custom key or value of the recipient. Don't send the payment then.(pay-invoice! invoice)(pay-invoice! invoice opts)Pay the BOLT 11 invoice from the wallet of the listener, with
opts as enable! takes them. It gives a promise of a map of the
:preimage and :proven?, or of a map with a diagnostic under :error.
The :proven? flag tells whether the preimage is the proof of the invoice. When it's false, the wallet says that it paid, and it gave no proof. Don't pay again then, since the wallet can have paid.
Pay the BOLT 11 `invoice` from the wallet of the listener, with `opts` as enable! takes them. It gives a promise of a map of the :preimage and :proven?, or of a map with a diagnostic under :error. The :proven? flag tells whether the preimage is the proof of the invoice. When it's false, the wallet says that it paid, and it gave no proof. Don't pay again then, since the wallet can have paid.
(pay-keysend! payment recipient)(pay-keysend! payment recipient opts)Pay payment to recipient with keysend from the wallet of the
listener, with opts as enable! takes them.
It gives a promise of a map of the :preimage and the :sats, or of a map with a diagnostic under :error. Nothing goes out for a payment below 1 sat, for a recipient that isn't a node, or for records that leave out the custom key or value of the recipient. The errors are then :value/below-one-sat, :value/not-a-node and :value/custom-record.
Pay `payment` to `recipient` with keysend from the wallet of the listener, with `opts` as enable! takes them. It gives a promise of a map of the :preimage and the :sats, or of a map with a diagnostic under :error. Nothing goes out for a payment below 1 sat, for a recipient that isn't a node, or for records that leave out the custom key or value of the recipient. The errors are then :value/below-one-sat, :value/not-a-node and :value/custom-record.
(provider)The WebLN provider of the page, or nil when the page has none.
The WebLN provider of the page, or nil when the page has none.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |