Skip to content

Instantly share code, notes, and snippets.

const bip21 = require("bip21");
let btcAdd = "bc1q0gf7ygdcwjxtfgmzlaqqtxn3s7sdamyw5v48a5";
let options = {
label: "Buy me Coffee",
message: "Let's test BIP21",
amount: 0.0005,
lightning:
"lnbc10u1p3pj257pp5yztkwjcz5ftl5laxkav23zmzekaw37zk6kmv80pk4xaev5qhtz7qdpdwd3xger9wd5kwm36yprx7u3qd36kucmgyp282etnv3shjcqzpgxqyz5vqsp5usyc4lk9chsfp53kvcnvq456ganh60d89reykdngsmtj6yw3nhvq9qyyssqjcewm5cjwz4a6rfjx77c490yced6pemk0upkxhy89cmm7sct66k8gneanwykzgdrwrfje69h9u5u0w57rrcsysas7gadwmzxc8c6t0spjazup6",
{
"name": "bip21",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"keywords": [],
"author": "",
@tobi-bams
tobi-bams / index.js
Created April 24, 2022 16:37
Get Balance from Bitcoin Core
const axios = require("axios");
const GetBalance = async () => {
const body = {
jsonrpc: "1.0",
method: "getbalance",
id: "curltext",
parameter: [],
};
const port = 38332;
@tobi-bams
tobi-bams / package.json
Created April 24, 2022 16:08
A sample of how Package.json file should look like
{
"name": "json-rpc",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"keywords": [],
"author": "",
@tobi-bams
tobi-bams / send_raw_tx.js
Created April 20, 2022 13:15
Send Raw Transaction
const { Axios } = require("./util/index");
const GetUnspentUtxo = async () => {
try {
const response = await Axios("listunspent");
// console.log(response.data.result);
return response.data.result;
} catch (error) {
console.log(error);
throw error;
@tobi-bams
tobi-bams / finalize_psbt.js
Last active April 20, 2022 13:14
Finalize PSBT transaction
const { Axios } = require("./util/index");
const GetUnspentUtxo = async () => {
try {
const response = await Axios("listunspent");
// console.log(response.data.result);
return response.data.result;
} catch (error) {
console.log(error);
throw error;
@tobi-bams
tobi-bams / sign_psbt.js
Created April 20, 2022 08:48
Signing PSBT
const { Axios } = require("./util/index");
const GetUnspentUtxo = async () => {
try {
const response = await Axios("listunspent");
// console.log(response.data.result);
return response.data.result;
} catch (error) {
console.log(error);
throw error;
@tobi-bams
tobi-bams / create_psbt_tx.js
Created April 20, 2022 08:14
Creating a PSBT transaction
const { Axios } = require("./util/index");
const GetUnspentUtxo = async () => {
try {
const response = await Axios("listunspent");
// console.log(response.data.result);
return response.data.result;
} catch (error) {
console.log(error);
throw error;
@tobi-bams
tobi-bams / selecting_utxo.js
Created April 20, 2022 07:56
This function selects unspent UTXOs to be used in a transaction
const { Axios } = require("./util/index");
const GetUnspentUtxo = async () => {
try {
const response = await Axios("listunspent");
return response.data.result;
} catch (error) {
throw error;
}
};
@tobi-bams
tobi-bams / unspentutxo.js
Created April 20, 2022 00:35
A function to get all the Unspent Utxos
const { Axios } = require("./util/index");
const GetUnspentUtxo = async () => {
try {
const response = await Axios("listunspent");
console.log(response.data.result);
return response.data.result;
} catch (error) {
console.log(error);
throw error;