~singpolyma/jmp-pay

446a4fd31de35f3494c63cd91545dd2bce0a70f3 — Christopher Vollick 2 years ago 3bf5956
Rubocop

Since these files didn't have shebangs, rubocop didn't look at them.
Once it started looking it found a bunch of stuff it didn't like, but
the original commit where they were written is already merged, so I'm
fixing those issues here.
M bin/check_electrum_wallet_completeness => bin/check_electrum_wallet_completeness +6 -5
@@ 1,10 1,10 @@
#!/usr/bin/ruby
# frozen_string_literal: true

require 'redis'
require 'dhall'
require_relative '../lib/redis_addresses'
require_relative '../lib/electrum'
require "redis"
require "dhall"
require_relative "../lib/redis_addresses"
require_relative "../lib/electrum"

config =
	Dhall::Coder


@@ 18,6 18,7 @@ electrum_addrs = electrum.listaddresses

get_addresses_with_users(redis).each do |addr, keys|
	unless electrum_addrs.include?(addr)
		puts "The address #{addr} (included in #{keys.join(", ")}) isn't included in electrum's list"
		puts "The address #{addr} (included in #{keys.join(', ')}) "\
			"isn't included in electrum's list"
	end
end

M bin/correct_duplicate_addrs => bin/correct_duplicate_addrs +6 -4
@@ 6,17 6,19 @@
# run this after looking into why
# Theoretically they could be piped together directly for automated fixing

require 'redis'
require "redis"

redis = Redis.new

customer_id = ENV['DEFAULT_CUSTOMER_ID']
customer_id = ENV["DEFAULT_CUSTOMER_ID"]
unless customer_id
	puts "The env-var DEFAULT_CUSTOMER_ID must be set to the ID of the customer who will receive the duplicated addrs, preferably a support customer or something linked to notifications when stray money is sent to these addresses"
	puts "The env-var DEFAULT_CUSTOMER_ID must be set to the ID of the customer "\
		"who will receive the duplicated addrs, preferably a support customer or "\
		"something linked to notifications when stray money is sent to these "\
		"addresses"
	exit 1
end


STDIN.each_line do |line|
	match = line.match(/^(\w+) is used by the following \d+ keys: (.*)/)
	unless match

M bin/detect_duplicate_addrs => bin/detect_duplicate_addrs +3 -3
@@ 1,13 1,13 @@
#!/usr/bin/ruby
# frozen_string_literal: true

require 'redis'
require_relative '../lib/redis_addresses'
require "redis"
require_relative "../lib/redis_addresses"

redis = Redis.new

get_addresses_with_users(redis).each do |addr, keys|
	if keys.length > 1
		puts "#{addr} is used by the following #{keys.length} keys: #{keys.join(" ")}"
		puts "#{addr} is used by the following #{keys.length} keys: #{keys.join(' ')}"
	end
end

M bin/reassert_electrum_notification => bin/reassert_electrum_notification +6 -5
@@ 1,10 1,10 @@
#!/usr/bin/ruby
# frozen_string_literal: true

require 'redis'
require 'dhall'
require_relative '../lib/redis_addresses'
require_relative '../lib/electrum'
require "redis"
require "dhall"
require_relative "../lib/redis_addresses"
require_relative "../lib/electrum"

config =
	Dhall::Coder


@@ 22,7 22,8 @@ get_addresses_with_users(redis).each do |addr, keys|
	end

	customer_id = match[1]
	url = "https://pay.jmp.chat/electrum_notify?address=#{addr}&customer_id=#{customer_id}"
	url = "https://pay.jmp.chat/electrum_notify?"\
		"address=#{addr}&customer_id=#{customer_id}"

	unless electrum.notify(addr, url)
		puts "Failed to setup #{addr} to notify #{url}. Skipping"