core-lightning/contrib/lightning-open-channel
Rusty Russell 8375857116 common: absorb remaining files from daemon/
Also, we split the more sophisticated json_add helpers to avoid pulling in
everything into lightning-cli, and unify the routines to print struct
short_channel_id (it's ':',  not '/' too).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-08-29 17:54:14 +02:00

19 lines
590 B
Bash
Executable File

#! /bin/sh -e
# A terrible script to fund a channel.
if [ $# -ne 3 ]; then
echo "Usage: <network-address> <portnum> <amount>" >&2
exit 1
fi
HOST="$1"
PORT="$2"
AMOUNT="$3"
NEWADDR=`cli/lightning-cli newaddr | sed -n 's/{ "address" : "\(.*\)" }/\1/p'`
TXID=`bitcoin-cli -testnet sendtoaddress $NEWADDR $AMOUNT`
RAWTX=`bitcoin-cli -testnet getrawtransaction $TXID`
echo "Connecting to $HOST port $PORT with $AMOUNT (minus fee) in address $NEWADDR tx $TXID"
echo "(Note: this will block until we get sufficient confirmations!)"
exec cli/lightning-cli connect "$HOST" "$PORT" $RAWTX