| marp | true |
|---|
Swiss Bitcoin Conference | 27. April 2024
beat@bitagent.ch | bitagent.ch | github.com/bitagentch/sbcapi24
- Bitcoin kaufen, sparen und verkaufen
- Technische Beratung zu Kauf, Eigenverwahrung und Verkauf
- Kaufen u.a. via Pocket REST API und 10% Gebühren sparen
- Weitere Dienste: Lightning Adresse, Nostr Identifier
- Bitcoin RPC API (JSON-RPC)
- Lightning Network Daemon LND API (gRPC, REST)
- LNURL Documents LUDs
- Nostr Implementation Possibilities NIPs
- LnPay Api und App https://lnpay.onrender.com
bitcoind
bitcoin-cli
- Port 8332
vi ~/.bitcoin/bitcoin.conf(restart bitcoind)
rpcuser=myusername
rpcpassword=mypassword
1.1 getblockcount
bitcoin-cli getblockcount
834404
curl --user bitagent \
--data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblockcount", "params": []}' \
-H 'content-type: text/plain;' \
http://127.0.0.1:8332/
{"result":834404,"error":null,"id":"curltest"}
node bitcoind-getblockcount.js
{
statusCode: 200,
body: { result: 834404, error: null, id: 'js-test' }
}
1.2 getblockhash
bitcoin-cli getblockhash 0
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
node bitcoind-getblockhash.js 0
{
statusCode: 200,
body: {
result: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
error: null,
id: 'js-test'
}
}
1.3 getblock
bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
height: 0, time: 1231006505
node bitcoind-getblock.js 0
Block 0 @ 2009-01-03T18:15:05.000Z
lnd
lncli
- Port 10009 gRpc
- Port 10080 Rest (default 8080)
vi ~/.lnd/lnd.conf
bitcoind.rpcuser=myusername
bitcoind.rpcpass=mypassword
2.1 GetState
lncli state
{ "state": "SERVER_ACTIVE" }
node lnd-get-state-grpc.js
{ state: 'SERVER_ACTIVE' }
node lnd-get-state-rest.js
{ statusCode: 200, body: { state: 'SERVER_ACTIVE' } }
2.2 AddInvoice
lncli addinvoice
{
"r_hash": "b5feeb250fc6d5f658a753a28a5f71506a13bdf07e9b4537ab4213170fe6e196",
"payment_request": "lnbc1pjlxh:t7cq6cezuw",
"add_index": "1",
"payment_addr": "25c28a4dfa111674ab22f5dfd24075d30f51621625fd1242eeedf479717e1b26"
}
node lnd-add-invoice.js
POST /v1/invoices
2.3 ListInvoices
lncli listinvoices
node lnd-list-invoices.js
GET /v1/invoices
2.4 LookupInvoice
lncli lookupinvoice 2af97d6c27366863dafb14f5b417fc1f12c7999c93b40d36afaa45bcb99fb69b
node lnd-lookup-invoice.js 2af97d6c27366863dafb14f5b417fc1f12c7999c93b40d36afaa45bcb99fb69b
GET /v1/invoice/{r_hash_str}
https://bitagent.ch/.well-known/lnurlp/beat
node lightning-address.js beat@bitagent.ch
{
tag: "payRequest"
callback: "https://bitagent.ch:443/.well-known/lnurlp/beat"
}
https://bitagent.ch/.well-known/lnurlp/beat?amount=1000&comment=Test
node lightning-address-pay.js beat@bitagent.ch
- LND AddInvoice
https://bitagent.ch/.well-known/nostr.json?name=beat
{
names: {
beat: "c36ca730cee5de659d4c673e876ebbc128ee271df6bb328b561da8c03f3449ba"
}
}
https://bitagent.ch/.well-known/lnurlp/beat
{
allowsNostr: true
nostrPubkey: "c36ca730cee5de659d4c673e876ebbc128ee271df6bb328b561da8c03f3449ba"
}
- LND LookupInvoice
- OpenApi
- https://github.com/OAI/OpenAPI-Specification
- Generierung von Doku (und Code)
- https://swagger.io/specification/v3/
ln-pay-api.yaml
npx redocly build-docs ln-pay-api.yaml --output ln-pay-api.html
npx yaml2json ln-pay-api.yaml > ln-pay-api.json
npm install @openapitools/openapi-generator-cli --save-dev
- Client Javascript https://openapi-generator.tech/docs/generators/javascript
npx @openapitools/openapi-generator-cli generate -i ln-pay-api.yaml -g javascript -o gen/javascript
node app.js
App listening on http://localhost:3000
npx cypress open
npx cypress run