This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
$ cat pay-using-channel.sh | |
#!/bin/sh | |
CHANNEL=$1 | |
BOLT11=$2 | |
[ -z "$CHANNEL" ] && echo "first program argument should be a short channel id and it is unset or set to the empty string" && exit 1 | |
[ -z "$BOLT11" ] && echo "second program argument should be a bolt11 invoice and it is unset or set to the empty string" && exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bitcoin::secp256k1::Secp256k1; | |
use electrum_client::ElectrumApi; | |
use electrum_client::Client; | |
use bitcoin::util::bip32; | |
use bitcoin::util::bip32::DerivationPath; | |
use bitcoin::Address; | |
use bitcoin::Network; | |
use std::str::FromStr; | |
fn main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# verify your available scaling frequency with: | |
# `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies` | |
# and adapt this script | |
unset FREQ | |
case $1 in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
use bitcoin::hashes::hex::{FromHex, ToHex}; | |
use bitcoin::schnorr::{KeyPair, PublicKey}; | |
use bitcoin::{Script, Address, Network, Transaction, TxIn, OutPoint, TxOut}; | |
use bitcoin::blockdata::{script, opcodes}; | |
use bitcoin::util::taproot::{TaprootSpendInfo, LeafVersion}; | |
use bitcoin::util::address::WitnessVersion; | |
use bitcoin::util::sighash::{SigHashCache, ScriptPath, SigHashType}; | |
use bitcoin::util::sighash::Prevouts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[test] | |
fn taproot_tests() { | |
let secp = Secp256k1::new(); | |
let secret = Vec::from_hex("6c068c2094c3f0986741cddbaff96399e338b4120671c6640216d3e474487a19").unwrap(); | |
let pair = KeyPair::from_seckey_slice(&secp, &secret).unwrap(); | |
let public = schnorr::PublicKey::from_keypair(&secp, &pair); | |
assert_eq!(public.to_hex(),"72ad3fb702bf1a2111b09c2bf1e72f4f52d4ceb2acdcfcd0c63abf70a59c36d6"); | |
let second_secret = Vec::from_hex("1cbb4d11a771697c1d86d0bbbcf0344b1e8b70d0cc794c3d9d6eff613390ba5e").unwrap(); | |
let second_pair = KeyPair::from_seckey_slice(&secp, &second_secret).unwrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cargo run --example repl --features cli-utils,esplora,electrum -- --wallet single_change_deep --descriptor "wpkh(tpubD6NzVbkrYhZ4YmSHJMXPEvd6dnPgH55EwGBs2AJHyiBgnT7zJzQ1ywHDxxZveoApLeBeSFcjysjQ5PebSg4gsdrVdRxCLAgHK8jKUiydMrg/*)" sync --max_addresses 200 | |
ADDRESS=$(cargo run --example repl --features cli-utils,esplora,electrum -- --wallet single_change_deep --descriptor "wpkh(tpubD6NzVbkrYhZ4YmSHJMXPEvd6dnPgH55EwGBs2AJHyiBgnT7zJzQ1ywHDxxZveoApLeBeSFcjysjQ5PebSg4gsdrVdRxCLAgHK8jKUiydMrg/*)" get_new_address | jq -r .address) | |
PSBT=$(cargo run --example repl --features cli-utils,esplora,electrum -- --wallet single_change_deep --descriptor "wpkh(tpubD6NzVbkrYhZ4YmSHJMXPEvd6dnPgH55EwGBs2AJHyiBgnT7zJzQ1ywHDxxZveoApLeBeSFcjysjQ5PebSg4gsdrVdRxCLAgHK8jKUiydMrg/*)" create_tx --to $ADDRESS:0 -a | jq -r .psbt) | |
bitcoin-cli decodepsbt $PSBT | |
OTHER_ADDRESS=$(cargo run --example repl --features cli-utils,esplora,electrum -- --wallet single_many_utxos --descriptor "wpkh(tpubD6NzVbkrYhZ4X2yy78HWrr1M9NT8dKeWfzNiQqDdMqqa9UmmGztG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The following is a proposal to expose SPV validation. | |
gdk-electrum has SPV validation for: | |
- bitcoin: headers chain is downloaded verified and saved in a flat file, tx proof is downloaded for every wallet tx, and checked against the headers. | |
- liquid: no need to download the chain, tx proof is downloaded, the header of the block containing the tx is downloaded, the proof is checked against the Merkle root in the header, script, and challenge of the header are verified | |
This functionality must be exposed (so we can SPV validate on ios and remove bitcoinj on android), for liquid is quite easy since it is not required to download the headers chain which is done in a thread in gdk-electrum (this may change with dynafed). Running a thread without a session is problematic (because you don't know if you need to close it), for this reason, I was thinking an interface like the following: | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use electrum_client::{Client, GetHistoryRes}; | |
use bitcoin::util::bip32::{ChildNumber, ExtendedPubKey}; | |
use bitcoin::secp256k1::{Secp256k1, All}; | |
use bitcoin::{Address, Network, Script, Transaction, BlockHeader}; | |
use bitcoin::consensus::{serialize, deserialize}; | |
use std::str::FromStr; | |
use std::time::Instant; | |
use std::collections::{HashSet, HashMap}; | |
use sled; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FEES_COLLECTED=$(lightning-cli getinfo | jq '.msatoshi_fees_collected / 1000') | |
AVERAGE_FORWARDED=$(lightning-cli listforwards | jq '.forwards[] | select (.status == "settled") | .in_msatoshi' | jq -s 'add / length / 1000') | |
PAYMENTS_FORWARDED=$(lightning-cli listforwards | jq '.forwards[] | select (.status == "settled") | .in_msatoshi' | jq -s 'length') | |
echo "Payments forwarded: $PAYMENTS_FORWARDED" | |
echo "Average payment forwarded: $AVERAGE_FORWARDED satoshi" | |
echo "Fees collected: $FEES_COLLECTED satoshi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from lightning import Plugin | |
import uuid | |
from paramiko import SSHClient | |
from scp import SCPClient | |
import io | |
plugin = Plugin() | |
@plugin.init() |
NewerOlder