wallets 2 ipfs
This commit is contained in:
parent
99a59a1325
commit
88e006bcdb
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# https://pad.p2p.legal/scuttlebot?both#Social-Layer-ScuttleBut-server
|
||||||
scuttlebutt() {
|
scuttlebutt() {
|
||||||
echo "TODO"
|
echo "TODO"
|
||||||
}
|
}
|
||||||
|
|
2
iptubes
2
iptubes
|
@ -1 +1 @@
|
||||||
Subproject commit 06e1a72d039d478a3fcf1341c1f7db1cae75b0e9
|
Subproject commit ea94ab06ea044c025bf583153c3f6e02beaac49b
|
|
@ -44,9 +44,9 @@ return 0
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# PUBLISH ~/.zen/wallets ON /ipns/$NODEIPNS
|
# PUBLISH ~/.zen/ipfs ON /ipns/$NODEIPNS
|
||||||
function wallets_ipfs_publish (){
|
function ipfs_ipfs_publish (){
|
||||||
IWALLETS=$(ipfs add -rHq '~/.zen/wallets' | tail -n 1)
|
IWALLETS=$(ipfs add -rHq '~/.zen/ipfs' | tail -n 1)
|
||||||
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
|
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
|
||||||
echo $IWALLETS
|
echo $IWALLETS
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@ DUNITERURL="https://$DUNITERNODE"
|
||||||
IPFSNODEID=$(ipfs id -f='<id>\n')
|
IPFSNODEID=$(ipfs id -f='<id>\n')
|
||||||
[[ $IPFSNODEID == "" ]] && echo "$USER Please Install IPFS !!" && exit 1
|
[[ $IPFSNODEID == "" ]] && echo "$USER Please Install IPFS !!" && exit 1
|
||||||
[[ ! -d ~/.zen/scan ]] && mkdir -p ~/.zen/scan # Directory containing G1 blockchain incoming TX Scan
|
[[ ! -d ~/.zen/scan ]] && mkdir -p ~/.zen/scan # Directory containing G1 blockchain incoming TX Scan
|
||||||
[[ ! -d ~/.zen/wallets ]] && mkdir -p ~/.zen/wallets # Directory where NODE store SMS & other Channel Wallets
|
[[ ! -d ~/.zen/ipfs ]] && mkdir -p ~/.zen/ipfs # Directory where NODE store SMS & other Channel Wallets
|
||||||
[[ ! -d ~/.zen/wallets_swarm ]] && mkdir -p ~/.zen/wallets_swarm # Local copy of all SSB friends IPFS Nodes published wallets
|
[[ ! -d ~/.zen/ipfs_swarm ]] && mkdir -p ~/.zen/ipfs_swarm # Local copy of all SSB friends IPFS Nodes published ipfs
|
||||||
|
|
||||||
#########################################################################################################
|
#########################################################################################################
|
||||||
# GET G1 PUBKEY FROM SCUTTLEBUTT or $2 (DEBUG)
|
# GET G1 PUBKEY FROM SCUTTLEBUTT or $2 (DEBUG)
|
||||||
|
|
|
@ -37,17 +37,17 @@ IPFSNODEID=$(ipfs id -f='<id>\n')
|
||||||
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
|
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
|
||||||
NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
||||||
|
|
||||||
# CREATE ~/.zen/wallets/.$IPFSNODEID/G1SSB
|
# CREATE ~/.zen/ipfs/.$IPFSNODEID/G1SSB
|
||||||
##############################################
|
##############################################
|
||||||
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFSNODEID NODE_G1PUBKEY" && exit 1
|
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFSNODEID NODE_G1PUBKEY" && exit 1
|
||||||
mkdir -p ~/.zen/wallets/.$IPFSNODEID/G1SSB
|
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/G1SSB
|
||||||
|
|
||||||
## PUBLISH ABOUT MESSAGE
|
## PUBLISH ABOUT MESSAGE
|
||||||
##############################################
|
##############################################
|
||||||
ssbpub=$(sbotc whoami | jq -r .id)
|
ssbpub=$(sbotc whoami | jq -r .id)
|
||||||
[[ $ssbpub == "" ]] && echo "ERROR missing ssb-server ?" && exit 1
|
[[ $ssbpub == "" ]] && echo "ERROR missing ssb-server ?" && exit 1
|
||||||
# G1 wallet QRCode
|
# G1 wallet QRCode
|
||||||
qrcodefile=~/.zen/wallets/.$IPFSNODEID/G1SSB/_g1.qrcode.png
|
qrcodefile=~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.qrcode.png
|
||||||
qrencode -s 5 -o $qrcodefile "$NODE_G1PUBKEY"
|
qrencode -s 5 -o $qrcodefile "$NODE_G1PUBKEY"
|
||||||
# Publish About message
|
# Publish About message
|
||||||
name=${qrcodefile##*/}
|
name=${qrcodefile##*/}
|
||||||
|
@ -55,10 +55,12 @@ id="$(sbotc blobs.add < $qrcodefile)"
|
||||||
type="$(file -b --mime-type $qrcodefile)"
|
type="$(file -b --mime-type $qrcodefile)"
|
||||||
size="$(wc -c < $qrcodefile)"
|
size="$(wc -c < $qrcodefile)"
|
||||||
# Publish About message
|
# Publish About message
|
||||||
sbot publish --type about --about $ssbpub --description "Astroport G1SSB Node\nipfs ls /ipns/$IPFSNODEID" --name "$USER@$(cat /etc/hostname)" --image "$id"
|
sbot publish --type about --about $ssbpub --description "Welcome to [Astroport](https://astroport.com) G1SSB/IPFS Station [$IPFSNODEID](http://$(cat /etc/hostname).local/ipns/$IPFSNODEID)" --name "$USER@$(cat /etc/hostname)" --image "$id"
|
||||||
sbotc publish '{"type":"post","text":"['"$name"']('"$id"')","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}'
|
#sbotc publish '{"type":"about","about":"'"$ssbpub"'","description":"Welcome to [Astroport](https://astroport.com) G1SSB/IPFS Station\nhttp://'$(cat /etc/hostname)'.local/ipns/$IPFSNODEID","name":'"'$USER'@'$(cat /etc/hostname)'"',"image":'"'$id'"'}'
|
||||||
|
|
||||||
|
sbotc publish '{"type":"post","text":"[G1SSB_Wallet.png]('"$id"')\nUse https://cesium.app to send payment.\nComment your transaction with '"'Zen'"' to order ZenTag...","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}'
|
||||||
|
|
||||||
# COPY NODE G1SSB ID to IPFS
|
# COPY NODE G1SSB ID to IPFS
|
||||||
echo "$ssbpub" > ~/.zen/wallets/.$IPFSNODEID/G1SSB/_ssb.whoami
|
echo "$ssbpub" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_ssb.whoami
|
||||||
echo "$NODE_G1PUBKEY" > ~/.zen/wallets/.$IPFSNODEID/G1SSB/_g1.pubkey
|
echo "$NODE_G1PUBKEY" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.pubkey
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,166 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# Image to HTML converter
|
||||||
|
# Copyright (C) January 2019 Neil Fraser
|
||||||
|
# https://neil.fraser.name/
|
||||||
|
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of version 2 of the GNU General
|
||||||
|
# Public License as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
# http://www.gnu.org/
|
||||||
|
|
||||||
|
# Loads JPEGs, PNGs and GIFs from websites and converts them to HTML.
|
||||||
|
# Usage: img2html.py?img=www.example.com/image.jpg
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
import cgi
|
||||||
|
import cStringIO
|
||||||
|
import math
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import urllib
|
||||||
|
|
||||||
|
|
||||||
|
# Throw a 500 error and terminate the program.
|
||||||
|
def die(msg):
|
||||||
|
print('Status:500')
|
||||||
|
print('Content-type: text/plain')
|
||||||
|
print('')
|
||||||
|
print('Error: ' + msg)
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
def is_valid_url(url):
|
||||||
|
regex = re.compile(
|
||||||
|
r'^https?://' # http:// or https://
|
||||||
|
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' # domain...
|
||||||
|
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or IP
|
||||||
|
r'(?::\d+)?' # optional port
|
||||||
|
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
|
||||||
|
return url is not None and regex.search(url)
|
||||||
|
|
||||||
|
form = cgi.FieldStorage()
|
||||||
|
if not form.has_key('img'):
|
||||||
|
die('"img" paramater not found.')
|
||||||
|
|
||||||
|
#rows = min(512+1, int(form['y'].value, 10))
|
||||||
|
|
||||||
|
remoteurl = form['img'].value
|
||||||
|
remoteurl = remoteurl.strip()
|
||||||
|
if not remoteurl:
|
||||||
|
die('No image URL specified.')
|
||||||
|
if not re.match('\\w+:\/\/', remoteurl):
|
||||||
|
remoteurl = 'http://' + remoteurl
|
||||||
|
if not is_valid_url(remoteurl):
|
||||||
|
die('Invalid image URL. Please go back and check the address.')
|
||||||
|
|
||||||
|
# Reduce load on my server, use cached tux.html if the request is tux.jpg
|
||||||
|
if remoteurl == 'https://neil.fraser.name/software/img2html/tux.jpg':
|
||||||
|
f = open('/home/neil/html/software/img2html/tux.html')
|
||||||
|
print("Content-type: text/html\n\n")
|
||||||
|
print(f.read())
|
||||||
|
f.close()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
try:
|
||||||
|
f = urllib.urlopen(remoteurl)
|
||||||
|
data = f.read()
|
||||||
|
except Exception as err:
|
||||||
|
die('Invalid image URL: %s' % err)
|
||||||
|
oldsize = int(round(len(data) / 1024))
|
||||||
|
|
||||||
|
cStr = cStringIO.StringIO(data)
|
||||||
|
image = Image.open(cStr)
|
||||||
|
image = image.convert('RGBA')
|
||||||
|
background = Image.new('RGBA', image.size, (255, 255, 255))
|
||||||
|
background.paste(image, mask=image.split()[3]) # 3 is the alpha channel
|
||||||
|
image = background
|
||||||
|
image = image.convert('RGB')
|
||||||
|
|
||||||
|
maxPixels = 100*100
|
||||||
|
(oldX, oldY) = image.size
|
||||||
|
if oldX * oldY > maxPixels:
|
||||||
|
factor = math.sqrt(maxPixels / float(oldX * oldY))
|
||||||
|
newX = int(round(oldX * factor))
|
||||||
|
newY = int(round(oldY * factor))
|
||||||
|
image.thumbnail((newX, newY), Image.ANTIALIAS)
|
||||||
|
msg = '[This image is too large to comfortably handle, so it has been scaled down to %s%% of its original size.]<P>' % int(100.0 * newX / oldX);
|
||||||
|
else:
|
||||||
|
newX = oldX
|
||||||
|
newY = oldY
|
||||||
|
msg = ''
|
||||||
|
|
||||||
|
|
||||||
|
# Scan the image pixel by pixel and build the HTML table.
|
||||||
|
table = '';
|
||||||
|
firstrow = True # Disable RLE for first row of each table segment (dodge Mozilla bug)
|
||||||
|
for y in range(newY):
|
||||||
|
row = '';
|
||||||
|
for x in range(newX):
|
||||||
|
try:
|
||||||
|
(r, g, b) = image.getpixel((x, y))
|
||||||
|
except:
|
||||||
|
# Some images throw a range error on some (transparent?) pixels.
|
||||||
|
(r, g, b) = (255, 255, 255)
|
||||||
|
if x == newX:
|
||||||
|
# Dummy run to clear the colspan buffer.
|
||||||
|
rgb = ''
|
||||||
|
else:
|
||||||
|
rgb = '%02x%02x%02x' % (r, g, b)
|
||||||
|
if x == 0: # Initialise the RLE (Run Length Encoding)
|
||||||
|
prev_rgb = rgb
|
||||||
|
span = 0
|
||||||
|
span += 1
|
||||||
|
if rgb != prev_rgb or firstrow:
|
||||||
|
if span == 1: # One pixel.
|
||||||
|
row += "<TD BGCOLOR=#%s><img width=1 height=1></TD>" % prev_rgb
|
||||||
|
else: # A run of multiple pixels with the same colour.
|
||||||
|
row += "<TD BGCOLOR=#%s COLSPAN=%d><img width=1 height=1></TD>" % (prev_rgb, span)
|
||||||
|
span = 0
|
||||||
|
prev_rgb = rgb
|
||||||
|
table += "<TR>%s</TR>\n" % row
|
||||||
|
|
||||||
|
# Segment the table so that MSIE renders it in pieces instead of waiting till the end.
|
||||||
|
if y != 0 and (y == 5 or y % 15 == 0) and y < newY - 10:
|
||||||
|
table += "</TABLE><TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>\n"
|
||||||
|
firstrow = True
|
||||||
|
else:
|
||||||
|
firstrow = False
|
||||||
|
newsize = int(round(len(table) / 1024))
|
||||||
|
|
||||||
|
|
||||||
|
# We're done. Now print it all out (this is what takes the time).
|
||||||
|
print("Content-type: text/html\n")
|
||||||
|
|
||||||
|
print("""
|
||||||
|
<HTML>
|
||||||
|
<HEAD>
|
||||||
|
<TITLE>img2html: {remoteurl}</TITLE>
|
||||||
|
</HEAD>
|
||||||
|
|
||||||
|
<BODY>
|
||||||
|
<DL>
|
||||||
|
<DT><B>Original Image</B>
|
||||||
|
<DD><A HREF="{remoteurl}">{remoteurl}</A>
|
||||||
|
<DD>{oldX}x{oldY}
|
||||||
|
<DD>{oldsize}KB
|
||||||
|
<P>
|
||||||
|
{msg}
|
||||||
|
<DT><B>Text Image</B>
|
||||||
|
<DD>{newX}x{newY}
|
||||||
|
<DD>{newsize}KB
|
||||||
|
<DD>
|
||||||
|
|
||||||
|
<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
|
||||||
|
{table}</TABLE>
|
||||||
|
|
||||||
|
<P>
|
||||||
|
<DT><B>Done</B>
|
||||||
|
</DL>
|
||||||
|
</BODY></HTML>
|
||||||
|
""".format(remoteurl=remoteurl, table=table, msg=msg,
|
||||||
|
oldsize=oldsize, newsize=newsize,
|
||||||
|
oldX=oldX, oldY=oldY, newX=newX, newY=newY))
|
|
@ -77,7 +77,7 @@ NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
||||||
AA=$(echo $($MY_PATH/tools/diceware.sh 6 | xargs) | sed s/\ /_/g ) # ZenTag Name = Diceware_6_words
|
AA=$(echo $($MY_PATH/tools/diceware.sh 6 | xargs) | sed s/\ /_/g ) # ZenTag Name = Diceware_6_words
|
||||||
AAH=$(echo -n ${AA} | sha256sum | cut -d ' ' -f 1) # ZenTag Name SHA256
|
AAH=$(echo -n ${AA} | sha256sum | cut -d ' ' -f 1) # ZenTag Name SHA256
|
||||||
# Create Unique Zentag for all IPFS SWARM!
|
# Create Unique Zentag for all IPFS SWARM!
|
||||||
while [[ $(grep -Rwl "$AA" ~/.zen/wallets_swarm/.Qm*/TAG/) ]]; do
|
while [[ $(grep -Rwl "$AA" ~/.zen/ipfs_swarm/.Qm*/TAG/) ]]; do
|
||||||
AA=$(echo $($MY_PATH/tools/diceware.sh 6 | xargs) | sed s/\ /_/g )
|
AA=$(echo $($MY_PATH/tools/diceware.sh 6 | xargs) | sed s/\ /_/g )
|
||||||
AAH=$(echo -n ${AA} | sha256sum | cut -d ' ' -f 1)
|
AAH=$(echo -n ${AA} | sha256sum | cut -d ' ' -f 1)
|
||||||
done
|
done
|
||||||
|
@ -175,8 +175,8 @@ J=$(ipfs name publish -k ${AA}.key --quieter /ipfs/${I})
|
||||||
echo "${J}" > ~/.zen/tag/${AAH}/_ipns
|
echo "${J}" > ~/.zen/tag/${AAH}/_ipns
|
||||||
|
|
||||||
# REPORT ZenTag to SWARM
|
# REPORT ZenTag to SWARM
|
||||||
mkdir -p ~/.zen/wallets/.$IPFSNODEID/TAG/
|
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/TAG/
|
||||||
echo "${AA}" > ~/.zen/wallets/.$IPFSNODEID/TAG/${J}
|
echo "${AA}" > ~/.zen/ipfs/.$IPFSNODEID/TAG/${J}
|
||||||
|
|
||||||
### G1TAG PRINT TYPE:DATA:IPNS
|
### G1TAG PRINT TYPE:DATA:IPNS
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -194,7 +194,7 @@ echo "##################################################################
|
||||||
ipfs pin ls -q --type recursive | xargs ipfs pin rm && ipfs repo gc
|
ipfs pin ls -q --type recursive | xargs ipfs pin rm && ipfs repo gc
|
||||||
rm -f ~/.ipfs/keystore/*.key
|
rm -f ~/.ipfs/keystore/*.key
|
||||||
rm -Rf ~/.zen/tag/*
|
rm -Rf ~/.zen/tag/*
|
||||||
rm -Rf ~/.zen/wallets/.$IPFSNODEID/TAG
|
rm -Rf ~/.zen/ipfs/.$IPFSNODEID/TAG
|
||||||
##################################################################"
|
##################################################################"
|
||||||
########################################################################
|
########################################################################
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue