Skip to content

Commit

Permalink
update to new more consistent upstream tag names
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguida committed Apr 23, 2024
1 parent a10b4e0 commit 4498615
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/install-cln.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ sudo apt-get install -y cargo rustfmt protobuf-compiler

pip3 install mako

git clone https://github.com/niftynei/lightning.git
git clone https://github.com/chrisguida/lightning.git
cd lightning
git checkout nifty/onchain_notif
git checkout cguida/onchain_notif

pip3 install -r plugins/clnrest/requirements.txt
pip3 install grpcio-tools
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This enables businesses to design a complete treasury using [Miniscript](https:/

## Prerequsites
- [`bitcoind`](https://github.com/bitcoin/bitcoin) with `scanblocks` RPC enabled (at least v24 and `blockfilterindex=1`)
- [`lightningd`](https://github.com/elementsproject/lightning) (aka Core Lightning aka CLN), built from [this branch](https://github.com/niftynei/lightning/tree/nifty/onchain_notif). (This branch adds the two new custom notification topics we use for Smaug: `utxo_deposit` and `utxo_spent`)
- [`lightningd`](https://github.com/elementsproject/lightning) (aka Core Lightning aka CLN), built from [this branch](https://github.com/chrisguida/lightning/tree/cguida/onchain_notif). (This branch adds the two new custom notification topics we use for Smaug: `utxo_deposit` and `utxo_spend`)

I recommend [`nix-bitcoin`](https://nixbitcoin.org) with a config [something like this](https://github.com/chrisguida/nix-dell)
- Obviously this is for mutinynet; if you want mainnet, edit your flake url to pull in the official nix-bitcoin repo)
Expand Down
7 changes: 3 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
clightning = prev.clightning.overrideAttrs {
version = "23.11";
src = prev.fetchFromGitHub {
owner = "niftynei";
owner = "chrisguida";
repo = "lightning";
#rev = "44c5b523683160e8c20bda200c6a5a59ea40bc5e";
rev = "37ad798a02336a82460b865fd4e6a29d8880856c";
sha256 = "sha256-pkXU4JB5Y2oN/2DfYNRgGJdH36Nz3gmVfC/Exv2E2Zk=";
rev = "ed418149f4d4e8d5457d67e508fc48dd7334acf7";
sha256 = "sha256-A/kR9ojv2d4/l+qaDklBEPN5GhMPqB9I9IGGjhMqVKk=";
fetchSubmodules = true;
};
};
Expand Down
1 change: 1 addition & 0 deletions result
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::path::{Path, PathBuf};
use std::sync::Arc;
use tokio::sync::Mutex;

use smaug::wallet::{AddArgs, DescriptorWallet, SMAUG_DATADIR, UTXO_DEPOSIT_TAG, UTXO_SPENT_TAG};
use smaug::wallet::{AddArgs, DescriptorWallet, SMAUG_DATADIR, UTXO_DEPOSIT_TAG, UTXO_SPEND_TAG};

use cln_plugin::{anyhow, messages, options, Builder, Error, Plugin};
use tokio;
Expand Down Expand Up @@ -73,7 +73,7 @@ async fn main() -> Result<(), anyhow::Error> {
"Bitcoind data directory (for cookie file access)",
))
.notification(messages::NotificationTopic::new(UTXO_DEPOSIT_TAG))
.notification(messages::NotificationTopic::new(UTXO_SPENT_TAG))
.notification(messages::NotificationTopic::new(UTXO_SPEND_TAG))
.rpcmethod(
"smaug",
"Watch one or more external wallet descriptors and emit notifications when coins are moved",
Expand Down
10 changes: 5 additions & 5 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::state::State;
pub const SMAUG_DATADIR: &str = ".smaug";

pub const UTXO_DEPOSIT_TAG: &str = "utxo_deposit";
pub const UTXO_SPENT_TAG: &str = "utxo_spent";
pub const UTXO_SPEND_TAG: &str = "utxo_spend";

/// Errors related to the `smaug` command.
#[derive(Debug)]
Expand Down Expand Up @@ -420,7 +420,7 @@ impl DescriptorWallet {
let amount = po.value;
let outpoint = format!("{}", input.previous_output.to_string());
log::trace!("outpoint = {}", format!("{}", outpoint));
let onchain_spend = json!({UTXO_SPENT_TAG: {
let onchain_spend = json!({UTXO_SPEND_TAG: {
"account": acct,
"outpoint": outpoint,
"spending_txid": tx.tx_node.txid,
Expand All @@ -433,7 +433,7 @@ impl DescriptorWallet {
let cloned_plugin = plugin.clone();
tokio::spawn(async move {
if let Err(e) = cloned_plugin
.send_custom_notification(UTXO_SPENT_TAG.to_string(), onchain_spend)
.send_custom_notification(UTXO_SPEND_TAG.to_string(), onchain_spend)
.await
{
log::error!("Error sending custom notification: {:?}", e);
Expand Down Expand Up @@ -582,7 +582,7 @@ impl DescriptorWallet {
let amount = po.value;
let outpoint = format!("{}", input.previous_output.to_string());
log::trace!("outpoint = {}", format!("{}", outpoint));
let onchain_spend = json!({UTXO_SPENT_TAG: {
let onchain_spend = json!({UTXO_SPEND_TAG: {
"account": acct,
"outpoint": outpoint,
"spending_txid": tx.tx_node.txid.to_string(),
Expand All @@ -595,7 +595,7 @@ impl DescriptorWallet {
let cloned_plugin = plugin.clone();
tokio::spawn(async move {
if let Err(e) = cloned_plugin
.send_custom_notification(UTXO_SPENT_TAG.to_string(), onchain_spend)
.send_custom_notification(UTXO_SPEND_TAG.to_string(), onchain_spend)
.await
{
log::error!("Error sending custom notification: {:?}", e);
Expand Down
8 changes: 4 additions & 4 deletions tests/test_bkpr_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def generate():
)

# ## simple spend ## #
# 1 input which is ours (send utxo_spent for 100M sats)
# 1 input which is ours (send utxo_spend for 100M sats)
# 2 outputs:
# 1 which is the 10M sat spend (to an external account)
# (send utxo_deposit from our account to external)
Expand All @@ -83,7 +83,7 @@ def generate():
# smaug wallet
# this subtracts 1M sat (+141 sats for fee) from our bitcoind wallet
# this will generate 3 more bkpr events for our smaug wallet:
# 1 utxo_spent for our input and 2 utxo_deposits for the outputs
# 1 utxo_spend for our input and 2 utxo_deposits for the outputs
cln_addr = ln_node.rpc.newaddr()["bech32"]
bitcoind.rpc.sendtoaddress(cln_addr, sats_to_btc(CLN_INITIAL_AMOUNT_SAT))
generate()
Expand All @@ -102,8 +102,8 @@ def generate():
# ## simple shared tx ## #
# payjoin where we pay 10M sats from smaug (ours) to CLN (theirs)
# 2 inputs
# 1 which is ours (89_999_859 sats) (send utxo_spent)
# 1 which is theirs (10M sats) (send utxo_spent)
# 1 which is ours (89_999_859 sats) (send utxo_spend)
# 1 which is theirs (10M sats) (send utxo_spend)
# 2 outputs
# 1 which is ours (79_998_859 sats)
# (utxo_deposit from our wallet to our wallet (basically change))
Expand Down

0 comments on commit 4498615

Please sign in to comment.