Skip to content

Commit

Permalink
validity check
Browse files Browse the repository at this point in the history
  • Loading branch information
dannydeezy committed Dec 11, 2023
1 parent 3169c73 commit e0dad76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 0 additions & 3 deletions deezy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
const axios = require('axios')

const { get_split_config } = require('./utils')
const BASE_URL = 'https://api.deezy.io/v1'

const VALID_SPLIT_TRIGGERS = ['NEVER', 'ALWAYS', 'NO_SATS']

function check_api_key() {
if (!process.env.DEEZY_API_KEY) {
throw new Error('DEEZY_API_KEY must be set')
Expand Down
6 changes: 6 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const {
get_existing_scan_config_by_utxo,
save_scan_config
} = require('./storage')
const VALID_SPLIT_TRIGGERS = ['NEVER', 'ALWAYS', 'NO_SATS']

function get_excluded_tags({ fee_rate }) {
let configured_excluded_tags = process.env.EXCLUDE_TAGS
Expand Down Expand Up @@ -93,6 +94,11 @@ function get_split_config({ utxo, fee_rate }) {
split_trigger = process.env.SPLIT_TRIGGER
split_target_size_sats = parseInt(process.env.SPLIT_UTXO_SIZE_SATS || 0)
}
if (split_trigger) {
if (!VALID_SPLIT_TRIGGERS.includes(process.env.SPLIT_TRIGGER)) {
throw new Error(`Invalid SPLIT_TRIGGER: ${process.env.SPLIT_TRIGGER}, must be one of ${VALID_SPLIT_TRIGGERS.join(', ')}`)
}
}
return { split_trigger, split_target_size_sats }
}

Expand Down

0 comments on commit e0dad76

Please sign in to comment.