Skip to content

Repository files navigation

Othello

Bitcoin-onlyLNNPMForkLicense: MIT

Othello banner

Usage

Install as dependency

$ npm install @krutt/othello
# OR
$ yarn add @krutt/othello

Usage

// importsimport{Othello}from'@krutt/othello'import{randomBytes}from'node:crypto'// On first usage, generate a secret for the backend LnMarkets account.letlnmSecret: string=randomBytes(16).toString('hex')letnetwork: string='mainnet'letothello: Othello=newOthello({ lnmSecret, network })// Login.awaitothello.login()// Create an invoice to deposit funds (amount in sats).letdepositInvoice=awaitothello.fetchDepositAddress({amountSats: 1000000,type: 'bolt11'})console.log(depositInvoice)// Create an on-chain address to deposit funds.letdepositAddress: string=awaitothello.fetchDepositAddress({type: 'on-chain'})console.log(depositAddress)// Get balances.letbalances=awaitothello.fetchBalances()console.log(balances)// Swap btc for $2 of usd.awaitothello.swap({from: 'btc',to: 'usd',amountUsd: 2})// Swap $1 of usd for btc.awaitothello.swap({from: 'usd',to: 'btc',amountUsd: 1})// Send funds from your othello wallet to a lightning invoice.letinvoice: string='lnbc1....'awaitothello.send({type: 'bolt11',address: invoice})// Send 100,000 sats from your othello wallet to an on-chain address.letonchainAddress: string='bc1...'awaitothello.send({type: 'on-chain',address: onchainAddress,amountSats: 100000,})

Examples

# First you may install tsx command using the following command `npm install -g tsx`
$ tsx example/credentials.ts
>

Degen: "But they're tracking me..." Othello: "No they're not, but try this"

$ tsx example/incognito.ts
>

License

This project is licensed under the terms of the MIT license.

About

Isolated-margin account for decentralized Bitcoin trading via the Lightning network.

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages