Skip to content

Instantly share code, notes, and snippets.

View tiero's full-sized avatar
🚀
Shipping

Marco Argentieri tiero

🚀
Shipping
View GitHub Profile
@tiero
tiero / nwc-openai.mjs
Created July 16, 2023 22:53 — forked from bumi/nwc-openai.mjs
NWC, L402, OpenAI example
import { fetchWithL402 } from "alby-tools";
import { webln } from "alby-js-sdk";
import 'websocket-polyfill';
import * as crypto from 'crypto'; // or 'node:crypto'
globalThis.crypto = crypto;
const nwcURL = process.env.NWC_URL;
async function main() {
const nwc = new webln.NWC({ nostrWalletConnectUrl: nwcURL });
@tiero
tiero / electrum.js
Last active December 14, 2022 15:51
const ElectrumClient = require('@mempool/electrum-client');
async function main() {
const client = new ElectrumClient(465, "blockstream.info", "ssl");
await client.initElectrum({ client: 'electrum-client-js', version: '1.4' }, {
retryPeriod: 5000,
maxRetry: 10,
pingPeriod: 5000,
@tiero
tiero / marina-example-advanced-spend.ts
Last active May 18, 2022 10:33
Spend an advanced transaction combining LDK and Marina Web Provider
import * as ecc from 'tiny-secp256k1';
import { AssetHash, confidential, networks, address, Psbt, script } from 'liquidjs-lib';
import { craftMultipleRecipientsPset, greedyCoinSelector, UnblindedOutput, AddressInterface } from 'ldk';
async function main() {
// 0. First, let's get our coins available from marina
// NOTICE: This is not yet deployed version yet 👉 https://github.com/vulpemventures/marina/issues/342
// Can be done now with LDK's `fetchAndUnblindUtxos` method
const coins = await window.marina.getCoins();
@tiero
tiero / tdex-liquidity-check.md
Last active February 1, 2022 18:08
How to check TDEX providers liquidity with BloomRPC

How to check TDEX providers liquidity with BloomRPC

Requirements

Provider endpoint

You need to know the provider endpoint first. A public list of providers can be found here

@tiero
tiero / decodePEMbase64url.js
Created November 15, 2021 15:42
Deocde a PEM certificate encoded as base64 url
const base64url = require('base64url')
const decodeUriComponent = require('decode-uri-component')
const fs = require('fs')
const untildify = require('untildify')
/**
* decode a tls certificate from a base64 encoded url string.
* @param {String} certString base64url encoded string to decode
* @return {String} decoded certificate
@tiero
tiero / docker-compose.yml
Last active November 9, 2021 18:27
tdexd with tor
version: "3.7"
services:
# TDEX daemon connected to Blockstream.info explorer
tdexd:
container_name: "tdexd"
image: ghcr.io/tdex-network/tdexd:latest
restart: unless-stopped
environment:
- TDEX_LOG_LEVEL=5 # 5 for Debug. 4 for production
/* MODIFIED BOOTSTRAP 4 – Custom BTCPay Server version.
*
* This file overrides the bootstrap variables with CSS custom properties
* that get defined in the root.scss file. Every variable we want to edit
* we need to set to a `--btcpay-` custom property and set it in the root.
*/
*,
*::before,
*::after {
@tiero
tiero / get-liquid-address.js
Last active December 23, 2021 10:50
LiquidJS HD Wallet Example
const bip39 = require("bip39")
const bip32 = require("bip32")
const slip77 = require("slip77")
const liquid = require('liquidjs-lib')
const regtest = liquid.networks.regtest
try {
const mnemonic = bip39.generateMnemonic()
const seed = await bip39.mnemonicToSeed(mnemonic)
@tiero
tiero / README.md
Last active November 6, 2019 08:51 — forked from EvgenyOrekhov/A simple Docker and Docker Compose install script for Ubuntu.md
A simple Docker and Docker Compose install script for Ubuntu

A simple Docker and Docker Compose install script for Ubuntu

Usage

  1. sh install-docker.sh
  2. log out
  3. log back in
  4. Run docker compose
@tiero
tiero / wallet.go
Created October 12, 2019 00:08
quick btc wallet in go
package wallet
import (
"github.com/btcsuite/btcd/btcec"
)
// Wallet define wallet structure
type Wallet struct {
PrivateKey *btcec.PrivateKey
PublicKey *btcec.PublicKey