Artifact b8ffe553e508ddf6119ec38ed32dd70d4f569c1ce49045f4f494211392f41a26:
- Executable file start-provider.sh — part of check-in [1323403adc] at 2023-09-17 07:45:02 on branch trunk — fix(doc): Fix sample startup script flags (user: carlos size: 1973)
0000: 23 21 2f 62 69 6e 2f 62 61 73 68 0a 0a 23 20 54 #!/bin/bash..# T 0010: 68 65 20 72 65 6c 61 79 73 20 75 73 65 64 20 62 he relays used b 0020: 79 20 74 68 69 73 20 70 72 6f 76 69 64 65 72 20 y this provider 0030: 74 6f 20 6c 69 73 74 65 6e 20 61 6e 64 20 72 65 to listen and re 0040: 61 63 74 20 74 6f 20 43 6c 69 65 6e 74 20 41 73 act to Client As 0050: 6b 73 0a 23 20 65 78 70 6f 72 74 20 50 4f 57 50 ks.# export POWP 0060: 55 42 5f 52 45 4c 41 59 53 3d 5b 22 77 73 73 3a UB_RELAYS=["wss: 0070: 2f 2f 72 65 6c 61 79 2e 64 61 6d 75 73 2e 69 6f //relay.damus.io 0080: 22 2c 22 77 73 73 3a 2f 2f 6e 6f 73 2e 6c 6f 6c ","wss://nos.lol 0090: 22 5d 0a 0a 23 20 4d 61 78 69 6d 75 6d 20 64 69 "]..# Maximum di 00a0: 66 66 69 63 75 6c 74 79 20 6f 66 20 61 20 43 6c fficulty of a Cl 00b0: 69 65 6e 74 20 41 73 6b 20 74 68 69 73 20 70 72 ient Ask this pr 00c0: 6f 76 69 64 65 72 20 69 73 20 77 69 6c 6c 69 6e ovider is willin 00d0: 67 20 74 6f 20 6d 69 6e 65 2c 20 6d 65 61 73 75 g to mine, measu 00e0: 72 65 64 20 69 6e 20 62 69 74 73 2e 20 41 6e 79 red in bits. Any 00f0: 20 43 6c 69 65 6e 74 20 41 73 6b 73 20 77 69 74 Client Asks wit 0100: 68 20 68 69 67 68 65 72 20 64 69 66 66 69 63 75 h higher difficu 0110: 6c 74 79 20 61 72 65 20 69 67 6e 6f 72 65 64 2e lty are ignored. 0120: 0a 23 20 48 65 78 20 72 65 71 75 65 73 74 73 20 .# Hex requests 0130: 68 61 76 65 20 34 20 62 69 74 73 20 70 65 72 20 have 4 bits per 0140: 63 68 61 72 61 63 74 65 72 2c 20 4e 70 75 62 20 character, Npub 0150: 72 65 71 75 65 73 74 73 20 68 61 76 65 20 35 20 requests have 5 0160: 62 69 74 73 20 70 65 72 20 63 68 61 72 61 63 74 bits per charact 0170: 65 72 2c 20 61 6e 64 20 50 6f 57 20 72 65 71 75 er, and PoW requ 0180: 65 73 74 73 20 65 78 70 6c 69 63 69 74 6c 79 20 ests explicitly 0190: 73 61 79 20 74 68 65 20 6e 75 6d 62 65 72 20 6f say the number o 01a0: 66 20 62 69 74 73 20 74 68 65 79 20 6e 65 65 64 f bits they need 01b0: 2e 0a 23 20 65 78 70 6f 72 74 20 50 4f 57 50 55 ..# export POWPU 01c0: 42 5f 50 52 4f 56 49 44 45 52 5f 4d 41 58 5f 4d B_PROVIDER_MAX_M 01d0: 49 4e 49 4e 47 5f 44 49 46 46 49 43 55 4c 54 59 INING_DIFFICULTY 01e0: 3d 32 35 0a 0a 23 20 57 68 65 6e 20 63 72 65 61 =25..# When crea 01f0: 74 69 6e 67 20 61 6e 20 69 6e 76 6f 69 63 65 20 ting an invoice 0200: 66 6f 72 20 61 20 43 6c 69 65 6e 74 20 41 73 6b for a Client Ask 0210: 2c 20 74 68 65 20 69 6e 76 6f 69 63 65 20 61 6d , the invoice am 0220: 6f 75 6e 74 20 77 69 6c 6c 20 62 65 20 62 61 73 ount will be bas 0230: 65 64 20 6f 6e 20 74 68 69 73 20 75 6e 69 74 20 ed on this unit 0240: 70 72 69 63 65 20 78 20 65 78 70 65 63 74 65 64 price x expected 0250: 20 6e 75 6d 62 65 72 20 6f 66 20 68 61 73 68 65 number of hashe 0260: 73 0a 23 20 75 6e 74 69 6c 20 61 20 6d 61 74 63 s.# until a matc 0270: 68 69 6e 67 20 70 75 62 6b 65 79 20 69 73 20 66 hing pubkey is f 0280: 6f 75 6e 64 2c 20 74 68 65 6e 20 65 76 65 72 79 ound, then every 0290: 74 68 69 6e 67 20 72 6f 75 6e 64 65 64 20 74 6f thing rounded to 02a0: 20 73 61 74 73 2e 0a 23 20 31 20 68 65 78 20 63 sats..# 1 hex c 02b0: 68 61 72 20 70 72 65 66 69 78 20 20 3d 20 31 36 har prefix = 16 02c0: 20 28 32 5e 34 29 20 65 78 70 65 63 74 65 64 20 (2^4) expected 02d0: 68 61 73 68 65 73 20 6f 6e 20 61 76 65 72 61 67 hashes on averag 02e0: 65 2c 20 32 20 68 65 78 20 63 68 61 72 20 70 72 e, 2 hex char pr 02f0: 65 66 69 78 20 20 3d 20 20 32 35 36 20 28 32 5e efix = 256 (2^ 0300: 38 29 20 65 78 70 65 63 74 65 64 20 68 61 73 68 8) expected hash 0310: 65 73 20 6f 6e 20 61 76 65 72 61 67 65 2c 20 65 es on average, e 0320: 74 63 0a 23 20 31 20 6e 70 75 62 20 63 68 61 72 tc.# 1 npub char 0330: 20 70 72 65 66 69 78 20 3d 20 33 32 20 28 32 5e prefix = 32 (2^ 0340: 35 29 20 65 78 70 65 63 74 65 64 20 68 61 73 68 5) expected hash 0350: 65 73 20 6f 6e 20 61 76 65 72 61 67 65 2c 20 32 es on average, 2 0360: 20 6e 70 75 62 20 63 68 61 72 20 70 72 65 66 69 npub char prefi 0370: 78 20 3d 20 31 30 32 34 20 28 32 5e 31 30 29 20 x = 1024 (2^10) 0380: 65 78 70 65 63 74 65 64 20 68 61 73 68 65 73 20 expected hashes 0390: 6f 6e 20 61 76 65 72 61 67 65 2c 20 65 74 63 0a on average, etc. 03a0: 23 20 69 6e 76 6f 69 63 65 5f 61 6d 6f 75 6e 74 # invoice_amount 03b0: 20 3d 20 50 4f 57 50 55 42 5f 50 52 4f 56 49 44 = POWPUB_PROVID 03c0: 45 52 5f 4d 53 41 54 53 5f 50 45 52 5f 45 58 50 ER_MSATS_PER_EXP 03d0: 45 43 54 45 44 5f 48 41 53 48 20 2a 20 28 65 78 ECTED_HASH * (ex 03e0: 70 65 63 74 65 64 20 68 61 73 68 65 73 20 6f 6e pected hashes on 03f0: 20 61 76 65 72 61 67 65 29 0a 23 20 54 68 65 20 average).# The 0400: 76 61 6c 75 65 20 68 61 73 20 74 6f 20 65 78 70 value has to exp 0410: 72 65 73 73 65 64 20 61 73 20 61 20 64 65 63 69 ressed as a deci 0420: 6d 61 6c 20 28 31 2e 30 2c 20 31 35 2e 30 2c 20 mal (1.0, 15.0, 0430: 31 2e 32 31 2c 20 33 2e 34 2c 20 65 74 63 29 2e 1.21, 3.4, etc). 0440: 0a 23 20 65 78 70 6f 72 74 20 50 4f 57 50 55 42 .# export POWPUB 0450: 5f 50 52 4f 56 49 44 45 52 5f 4d 53 41 54 53 5f _PROVIDER_MSATS_ 0460: 50 45 52 5f 45 58 50 45 43 54 45 44 5f 48 41 53 PER_EXPECTED_HAS 0470: 48 3d 30 2e 32 31 0a 0a 23 20 50 72 6f 76 69 64 H=0.21..# Provid 0480: 65 72 27 73 20 6e 6f 73 74 72 20 70 72 69 76 61 er's nostr priva 0490: 74 65 20 6b 65 79 2c 20 69 6e 20 6e 73 65 63 20 te key, in nsec 04a0: 66 6f 72 6d 61 74 20 28 62 65 63 68 33 32 29 20 format (bech32) 04b0: 6f 72 20 6c 65 67 61 63 79 20 68 65 78 2e 0a 23 or legacy hex..# 04c0: 20 49 66 20 6e 6f 74 20 73 65 74 2c 20 61 20 6e If not set, a n 04d0: 65 77 20 72 61 6e 64 6f 6d 20 6f 6e 65 20 69 73 ew random one is 04e0: 20 67 65 6e 65 72 61 74 65 64 20 6f 6e 20 65 61 generated on ea 04f0: 63 68 20 73 74 61 72 74 75 70 20 61 6e 64 20 70 ch startup and p 0500: 72 69 6e 74 65 64 20 69 6e 20 74 68 65 20 63 6f rinted in the co 0510: 6e 73 6f 6c 65 2e 0a 23 20 54 6f 20 61 63 63 75 nsole..# To accu 0520: 6d 75 6c 61 74 65 20 72 65 70 75 74 61 74 69 6f mulate reputatio 0530: 6e 2c 20 69 74 27 73 20 72 65 63 6f 6d 6d 65 6e n, it's recommen 0540: 64 65 64 20 74 6f 20 73 65 74 20 74 68 69 73 20 ded to set this 0550: 68 65 72 65 2c 20 73 75 63 68 20 74 68 61 74 20 here, such that 0560: 65 76 65 6e 20 61 66 74 65 72 20 61 20 72 65 73 even after a res 0570: 74 61 72 74 2c 20 74 68 65 20 70 72 6f 76 69 64 tart, the provid 0580: 65 72 20 77 69 6c 6c 20 75 73 65 20 74 68 65 20 er will use the 0590: 73 61 6d 65 20 6b 65 79 2e 0a 23 20 65 78 70 6f same key..# expo 05a0: 72 74 20 50 4f 57 50 55 42 5f 50 52 4f 56 49 44 rt POWPUB_PROVID 05b0: 45 52 5f 4e 4f 53 54 52 5f 50 52 56 5f 4b 45 59 ER_NOSTR_PRV_KEY 05c0: 3d 0a 0a 23 20 4f 70 74 69 6f 6e 20 31 3a 20 55 =..# Option 1: U 05d0: 73 69 6e 67 20 4c 4e 44 20 66 6f 72 20 69 6e 76 sing LND for inv 05e0: 6f 69 63 69 6e 67 0a 65 78 70 6f 72 74 20 50 4f oicing.export PO 05f0: 57 50 55 42 5f 4c 4e 44 5f 52 45 53 54 5f 41 50 WPUB_LND_REST_AP 0600: 49 5f 55 52 4c 3d 68 74 74 70 73 3a 2f 2f 6c 6e I_URL=https://ln 0610: 64 3a 70 6f 72 74 0a 65 78 70 6f 72 74 20 50 4f d:port.export PO 0620: 57 50 55 42 5f 4c 4e 44 5f 4d 41 43 41 52 4f 4f WPUB_LND_MACAROO 0630: 4e 5f 50 41 54 48 3d 2f 70 61 74 68 2f 74 6f 2f N_PATH=/path/to/ 0640: 6c 6e 64 2f 61 64 6d 69 6e 2e 6d 61 63 61 72 6f lnd/admin.macaro 0650: 6f 6e 0a 65 78 70 6f 72 74 20 50 4f 57 50 55 42 on.export POWPUB 0660: 5f 4c 4e 44 5f 43 45 52 54 5f 50 41 54 48 3d 2f _LND_CERT_PATH=/ 0670: 70 61 74 68 2f 74 6f 2f 6c 6e 64 2f 74 6c 73 2e path/to/lnd/tls. 0680: 63 65 72 74 0a 52 55 53 54 46 4c 41 47 53 3d 22 cert.RUSTFLAGS=" 0690: 2d 43 74 61 72 67 65 74 2d 63 70 75 3d 6e 61 74 -Ctarget-cpu=nat 06a0: 69 76 65 22 20 63 61 72 67 6f 20 72 75 6e 20 2d ive" cargo run - 06b0: 2d 72 65 6c 65 61 73 65 20 2d 2d 66 65 61 74 75 -release --featu 06c0: 72 65 73 3d 63 6c 69 65 6e 74 2d 6c 6e 64 20 2d res=client-lnd - 06d0: 2d 65 78 61 6d 70 6c 65 20 70 72 6f 76 69 64 65 -example provide 06e0: 72 0a 0a 23 20 4f 70 74 69 6f 6e 20 32 3a 20 55 r..# Option 2: U 06f0: 73 69 6e 67 20 61 20 4c 4e 20 41 64 64 72 65 73 sing a LN Addres 0700: 73 20 66 6f 72 20 69 6e 76 6f 69 63 69 6e 67 0a s for invoicing. 0710: 23 20 65 78 70 6f 72 74 20 50 4f 57 50 55 42 5f # export POWPUB_ 0720: 50 52 4f 56 49 44 45 52 5f 4c 4e 5f 41 44 44 52 PROVIDER_LN_ADDR 0730: 45 53 53 3d 22 79 6f 75 72 40 6c 69 67 68 74 6e ESS="your@lightn 0740: 69 6e 67 5f 61 64 64 72 65 73 73 2e 63 6f 6d 22 ing_address.com" 0750: 0a 23 20 52 55 53 54 46 4c 41 47 53 3d 22 2d 43 .# RUSTFLAGS="-C 0760: 74 61 72 67 65 74 2d 63 70 75 3d 6e 61 74 69 76 target-cpu=nativ 0770: 65 22 20 63 61 72 67 6f 20 72 75 6e 20 2d 2d 72 e" cargo run --r 0780: 65 6c 65 61 73 65 20 2d 2d 66 65 61 74 75 72 65 elease --feature 0790: 73 3d 63 6c 69 65 6e 74 2d 6c 6e 61 64 64 72 65 s=client-lnaddre 07a0: 73 73 20 2d 2d 65 78 61 6d 70 6c 65 20 70 72 6f ss --example pro 07b0: 76 69 64 65 72 vider