As the faucet will always ask for a captcha now, the current script is
no longer usable.
Change the script to print the captcha in dot-matrix to the terminal,
using unicode Braille characters.
'''Print black-and-white image to terminal in braille unicode characters.'''
x_blocks=(img.size[0]+BW-1)//BW
y_blocks=(img.size[1]+BH-1)//BH
forybinrange(y_blocks):
line=[]
forxbinrange(x_blocks):
ch=BASE
foryinrange(BH):
forxinrange(BW):
try:
val=img.getpixel((xb*BW+x,yb*BH+y))
exceptIndexError:
pass
else:
ifval[0]<threshold:
ch|=BIT_PER_PIXEL[y][x]
line.append(chr(ch))
print(''.join(line))
parser=argparse.ArgumentParser(description='Script to get coins from a faucet.',epilog='You may need to start with double-dash (--) when providing bitcoin-cli arguments.')
parser=argparse.ArgumentParser(description='Script to get coins from a faucet.',epilog='You may need to start with double-dash (--) when providing bitcoin-cli arguments.')
parser.add_argument('-c','--cmd',dest='cmd',default='bitcoin-cli',help='bitcoin-cli command to use')
parser.add_argument('-c','--cmd',dest='cmd',default='bitcoin-cli',help='bitcoin-cli command to use')
parser.add_argument('-f','--faucet',dest='faucet',default=DEFAULT_GLOBAL_FAUCET,help='URL of the faucet')
parser.add_argument('-f','--faucet',dest='faucet',default=DEFAULT_GLOBAL_FAUCET,help='URL of the faucet')
parser.add_argument('-g','--captcha',dest='captcha',default=DEFAULT_GLOBAL_CAPTCHA,help='URL of the faucet captcha, or empty if no captcha is needed')
parser.add_argument('-a','--addr',dest='addr',default='',help='Bitcoin address to which the faucet should send')
parser.add_argument('-a','--addr',dest='addr',default='',help='Bitcoin address to which the faucet should send')
parser.add_argument('-p','--password',dest='password',default='',help='Faucet password, if any')
parser.add_argument('-p','--password',dest='password',default='',help='Faucet password, if any')
parser.add_argument('-n','--amount',dest='amount',default='0.001',help='Amount to request (0.001-0.1, default is 0.001)')
parser.add_argument('-i','--imagemagick',dest='imagemagick',default=CONVERT,help='Path to imagemagick convert utility')
parser.add_argument('bitcoin_cli_args',nargs='*',help='Arguments to pass on to bitcoin-cli (default: -signet)')
parser.add_argument('bitcoin_cli_args',nargs='*',help='Arguments to pass on to bitcoin-cli (default: -signet)')
args=parser.parse_args()
args=parser.parse_args()
@ -43,14 +102,43 @@ if args.faucet.lower() == DEFAULT_GLOBAL_FAUCET:
ifcurr_signet_hash!=GLOBAL_FIRST_BLOCK_HASH:
ifcurr_signet_hash!=GLOBAL_FIRST_BLOCK_HASH:
print('The global faucet cannot be used with a custom Signet network. Please use the global signet or setup your custom faucet to use this functionality.\n')
print('The global faucet cannot be used with a custom Signet network. Please use the global signet or setup your custom faucet to use this functionality.\n')
exit(1)
exit(1)
else:
# For custom faucets, don't request captcha by default.
print('The binary',args.imagemagick,'could not be found. Please make sure ImageMagick (or a compatible fork) is installed and that the correct path is specified.')
exit(1)
img=PPMImage(io.BytesIO(rv.stdout))
# Terminal interaction
print_image(img)
print('Enter captcha: ',end='')
data['captcha']=input()
try:
try:
res=requests.post(args.faucet,data=data)
res=session.post(args.faucet,data=data)
except:
except:
print('Unexpected error when contacting faucet:',sys.exc_info()[0])
print('Unexpected error when contacting faucet:',sys.exc_info()[0])