mirror of
https://github.com/aljazceru/BitcoinAndLightningLayerSpecs.github.io.git
synced 2025-12-17 05:54:22 +01:00
253 lines
11 KiB
HTML
253 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html class="writer-html5" lang="en" >
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<link rel="shortcut icon" href="../../img/favicon.ico" />
|
|
<title>makeInvoice - WebBTC Specification</title>
|
|
<link rel="stylesheet" href="../../css/theme.css" />
|
|
<link rel="stylesheet" href="../../css/theme_extra.css" />
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/github.min.css" />
|
|
<link href="../../css/custom.css" rel="stylesheet" />
|
|
|
|
<script>
|
|
// Current page data
|
|
var mkdocs_page_name = "makeInvoice";
|
|
var mkdocs_page_input_path = "invoices/makeInvoice.md";
|
|
var mkdocs_page_url = null;
|
|
</script>
|
|
|
|
<script src="../../js/jquery-3.6.0.min.js" defer></script>
|
|
<!--[if lt IE 9]>
|
|
<script src="../../js/html5shiv.min.js"></script>
|
|
<![endif]-->
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/languages/javascript.min.js"></script>
|
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
</head>
|
|
|
|
<body class="wy-body-for-nav" role="document">
|
|
|
|
<div class="wy-grid-for-nav">
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
|
|
<div class="wy-side-scroll">
|
|
<div class="wy-side-nav-search">
|
|
<a href="../.." class="icon icon-home"> WebBTC Specification
|
|
</a><div role="search">
|
|
<form id ="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
|
<input type="text" name="q" placeholder="Search docs" title="Type search term here" />
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../..">Overview</a>
|
|
</li>
|
|
</ul>
|
|
<p class="caption"><span class="caption-text">API Reference</span></p>
|
|
<ul class="current">
|
|
<li class="toctree-l1"><a class="reference internal" href="#">Enable</a>
|
|
<ul>
|
|
<li class="toctree-l2"><a class="reference internal" href="../../enable/">Enabling</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1"><a class="reference internal" href="#">Information</a>
|
|
<ul>
|
|
<li class="toctree-l2"><a class="reference internal" href="../../info/">info</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1"><a class="reference internal" href="#">Signatures</a>
|
|
<ul>
|
|
<li class="toctree-l2"><a class="reference internal" href="../../signatures/sign/">Signing</a>
|
|
</li>
|
|
<li class="toctree-l2"><a class="reference internal" href="../../signatures/verify/">Verification</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1 current"><a class="reference internal current" href="#">Invoices</a>
|
|
<ul class="current">
|
|
<li class="toctree-l2 current"><a class="reference internal current" href="./">makeInvoice</a>
|
|
<ul class="current">
|
|
<li class="toctree-l3"><a class="reference internal" href="#syntax">Syntax</a>
|
|
</li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#parameters">Parameters</a>
|
|
</li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#returns">Returns</a>
|
|
</li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#example">Example</a>
|
|
</li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#considerations">Considerations</a>
|
|
</li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#notes">Notes</a>
|
|
</li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#reference">Reference</a>
|
|
</li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#invoice-address-description">Invoice address description</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l2"><a class="reference internal" href="../../transactions/send/">sendPayment</a>
|
|
</li>
|
|
<li class="toctree-l2"><a class="reference internal" href="../../transactions/sendTransaction/">sendTransaction</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1"><a class="reference internal" href="#">Addresses</a>
|
|
<ul>
|
|
<li class="toctree-l2"><a class="reference internal" href="../../addresses/getAddress/">getAddress</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1"><a class="reference internal" href="../../extendability/extending/">Extending</a>
|
|
</li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../../squatting/">Namespace Squatting</a>
|
|
</li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../../references/">Resources</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
<nav class="wy-nav-top" role="navigation" aria-label="Mobile navigation menu">
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
<a href="../..">WebBTC Specification</a>
|
|
|
|
</nav>
|
|
<div class="wy-nav-content">
|
|
<div class="rst-content"><div role="navigation" aria-label="breadcrumbs navigation">
|
|
<ul class="wy-breadcrumbs">
|
|
<li><a href="../.." class="icon icon-home" alt="Docs"></a> »</li>
|
|
<li>API Reference »</li>
|
|
<li>Invoices »</li><li>makeInvoice</li>
|
|
<li class="wy-breadcrumbs-aside">
|
|
</li>
|
|
</ul>
|
|
<hr/>
|
|
</div>
|
|
|
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
<div class="section" itemprop="articleBody">
|
|
|
|
<h1 id="create-a-new-invoice">Create a new invoice</h1>
|
|
<p>The <code>makeInvoice</code> method is used to generate a new invoice.</p>
|
|
<h2 id="syntax">Syntax</h2>
|
|
<pre><code>makeInvoice(Object)
|
|
</code></pre>
|
|
<h2 id="parameters">Parameters</h2>
|
|
<ul>
|
|
<li>Object<ul>
|
|
<li>amount : string | number <span class="badge">Optional</span></li>
|
|
<li>defaultMemo : string <span class="badge">Optional</span></li>
|
|
<li>label : string <span class="badge">Optional</span></li>
|
|
<li>message : string <span class="badge">Optional</span></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<blockquote>
|
|
<p><strong><em>NOTE:</em></strong><br />
|
|
Providing any of the above would result in a pre-populating a a prompt which requires the user to complete the rest of the information.
|
|
e.g. Only providing the amount parameter might result in the following prompt.</p>
|
|
</blockquote>
|
|
<p><img src="/assets/makeinvoice.png" style="width:200px;"/></p>
|
|
<h2 id="returns">Returns</h2>
|
|
<ul>
|
|
<li>Object<ul>
|
|
<li>paymentRequest: string; <span class="badge">LN Invoice</span></li>
|
|
<li>BIP21 address string; <span class="badge">Onchain BIP 21 URI</span></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<h2 id="example">Example</h2>
|
|
<pre><code>await window.webln.makeInvoice({})
|
|
{
|
|
paymentRequest: 'lnbc10n1p3x9thxpp59xj4cmm26jnpnrfekgncyj42e9lxredz…734s07kxt8hl2s6wuv20kh7kw7h5lurtmyscsrwgkgptn4z2j', rHash: '29a55c6f6ad4a6198d39b227824aaac97e61e5a2428db7dab7f8b097ae5d28ca'
|
|
}
|
|
</code></pre>
|
|
<pre><code>window.bitcoin.makeInvoice({amount:1, label: 'Label', message: 'Message'})
|
|
|
|
bitcoin:address?amount=0&label=Label&message=Message
|
|
</code></pre>
|
|
<h2 id="considerations">Considerations</h2>
|
|
<p>These parameters might not be required in the spec as they are used by the website for convenience purposes in setting up the invoice dialog.</p>
|
|
<p>defaultAmount?: string | number;
|
|
minimumAmount?: string | number;
|
|
maximumAmount?: string | number;</p>
|
|
<h2 id="notes">Notes</h2>
|
|
<p>The amount parameter doesn't distinguish between bitcoin and satoshis</p>
|
|
<h2 id="reference">Reference</h2>
|
|
<p>https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki</p>
|
|
<pre><code>bitcoinurn = "bitcoin:" bitcoinaddress [ "?" bitcoinparams ]
|
|
bitcoinaddress = *base58
|
|
bitcoinparams = bitcoinparam [ "&" bitcoinparams ]
|
|
bitcoinparam = [ amountparam / labelparam / messageparam / otherparam / reqparam ]
|
|
amountparam = "amount=" *digit [ "." *digit ]
|
|
labelparam = "label=" *qchar
|
|
messageparam = "message=" *qchar
|
|
otherparam = qchar *qchar [ "=" *qchar ]
|
|
reqparam = "req-" qchar *qchar [ "=" *qchar ]
|
|
</code></pre>
|
|
<h2 id="invoice-address-description">Invoice address description</h2>
|
|
<p><a href="https://en.bitcoin.it/wiki/Invoice_address">Invoice Address</a>
|
|
<a href="https://github.com/lightning/blips/pull/11/files?short_path=1efcc79#diff-1efcc7957e02dad2d5a9deea7032635c9f19100d5a7ee08be166cb1dc9b4d690">Meno proposal</a>
|
|
<a href="https://doc.clickup.com/18307877/d/h/hept5-1721/f06e5c5e4eba551/hept5-421">Payment Requests</a></p>
|
|
<p>Separate Meno into name and description</p>
|
|
<p>Label = The who
|
|
Message = The what</p>
|
|
|
|
</div>
|
|
</div><footer>
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="Footer Navigation">
|
|
<a href="../../signatures/verify/" class="btn btn-neutral float-left" title="Verification"><span class="icon icon-circle-arrow-left"></span> Previous</a>
|
|
<a href="../../transactions/send/" class="btn btn-neutral float-right" title="sendPayment">Next <span class="icon icon-circle-arrow-right"></span></a>
|
|
</div>
|
|
|
|
<hr/>
|
|
|
|
<div role="contentinfo">
|
|
<!-- Copyright etc -->
|
|
</div>
|
|
|
|
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
</footer>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
<div class="rst-versions" role="note" aria-label="Versions">
|
|
<span class="rst-current-version" data-toggle="rst-current-version">
|
|
|
|
|
|
<span><a href="../../signatures/verify/" style="color: #fcfcfc">« Previous</a></span>
|
|
|
|
|
|
<span><a href="../../transactions/send/" style="color: #fcfcfc">Next »</a></span>
|
|
|
|
</span>
|
|
</div>
|
|
<script>var base_url = '../..';</script>
|
|
<script src="../../js/theme_extra.js" defer></script>
|
|
<script src="../../js/theme.js" defer></script>
|
|
<script src="../../search/main.js" defer></script>
|
|
<script defer>
|
|
window.onload = function () {
|
|
SphinxRtdTheme.Navigation.enable(true);
|
|
};
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|