Post
Topic
Board Project Development
Re: 100btc Bounty for a "Donate Bitcoin" button .
by
grondilu
on 27/12/2010, 00:43:48 UTC

We should not adapt to people's intellectual laziness.  Ultimately they'll grow up and understand why a plain ASCII address is better.


 Angry Ugh! I am so tired of that attitude!

I am always flabbergasted at the irony of cyber-luddites whining about how ease of use and user friendliness are abominations unto the net.

Well, the URI idea is ok.  Assuming a uri of the form "bitcoin:address#amount[%comment]", I suggest the following URI handler program :

Code:
#!/bin/bash

urldecode() { echo -e "$(sed 'y/+/ /; s/%/\\x/g')"; }
error() {
    if [[ -n "$DISPLAY" ]]
    then zenity --error --text "$*"
    else echo "$*" 2>&1
    fi
    return 1
}

question() {
    echo -n "Do you want to send $1 BTC to this address $2 "
    if [[ -n "$3" ]]
    then echo -n "with '$3' as a comment"
    fi
    echo "?" ;
}

if
    uri="${uri#bitcoin:}"
    [[ -z "$uri" ]]
then error "usage: $0 bitcoin-URI"
elif
    addr="${uri%#*}"
    [[ ! "$addr" =~ ^[1-9a-km-zA-HJ-NP-Z]{34}$ ]]
then error "Wrong address format"
elif
    s=${uri##*#}
    amount=${s%\%*}
    [[ ! "$amount" =~ ^([1-9][0-9]*\.{,1}[0-9]*|0\.[0-9]*)$ ]]
then error "Wrong amount format"
    echo $_
elif comment="${uri##*%}"
    [[ -n "$DISPLAY" ]]
then
    zenity --question --text "$(question $amount $addr $comment)"
else
    read -p "$(question $amount $addr $comment) (y/N) " answer
    [[ "$answer" =~ ^[yY]$ ]]
fi &&

bitcoind sendtoaddress $addr $amount "$comment"