diff --git a/daemon/controlled_time.c b/daemon/controlled_time.c index d95556552..5bf80917b 100644 --- a/daemon/controlled_time.c +++ b/daemon/controlled_time.c @@ -65,7 +65,7 @@ static void json_mocktime(struct command *cmd, command_success(cmd, response); } -const struct json_command mocktime_command = { +const struct json_command dev_mocktime_command = { "dev-mocktime", json_mocktime, "Set current time to {mocktime} seconds (0 to return to normal)", diff --git a/daemon/jsonrpc.c b/daemon/jsonrpc.c index 52220b348..7408fc309 100644 --- a/daemon/jsonrpc.c +++ b/daemon/jsonrpc.c @@ -43,27 +43,6 @@ static const struct json_command help_command = { "[] if specified gives details about a single command." }; -static void json_echo(struct command *cmd, - const char *buffer, const jsmntok_t *params) -{ - struct json_result *response = new_json_result(cmd); - - json_object_start(response, NULL); - json_add_num(response, "num", params->size); - json_add_literal(response, "echo", - json_tok_contents(buffer, params), - json_tok_len(params)); - json_object_end(response); - command_success(cmd, response); -} - -static const struct json_command echo_command = { - "dev-echo", - json_echo, - "echo parameters", - "Simple echo test for developers" -}; - static void json_stop(struct command *cmd, const char *buffer, const jsmntok_t *params) { @@ -225,7 +204,7 @@ static void json_rhash(struct command *cmd, command_success(cmd, response); } -static const struct json_command rhash_command = { +static const struct json_command dev_rhash_command = { "dev-rhash", json_rhash, "SHA256 of {secret}", @@ -238,7 +217,7 @@ static void json_crash(struct command *cmd, fatal("Crash at user request"); } -static const struct json_command crash_command = { +static const struct json_command dev_crash_command = { "dev-crash", json_crash, "Call fatal().", @@ -269,7 +248,7 @@ static void json_restart(struct command *cmd, command_success(cmd, null_response(cmd)); } -static const struct json_command restart_command = { +static const struct json_command dev_restart_command = { "dev-restart", json_restart, "Re-exec the given {binary}.", @@ -283,10 +262,6 @@ static const struct json_command *cmdlist[] = { &connect_command, &getpeers_command, &gethtlcs_command, - &newhtlc_command, - &fulfillhtlc_command, - &failhtlc_command, - &commit_command, &close_command, &newaddr_command, &invoice_command, @@ -295,19 +270,22 @@ static const struct json_command *cmdlist[] = { &waitinvoice_command, &getroute_command, &sendpay_command, - &feerate_command, /* Developer/debugging options. */ - &echo_command, - &rhash_command, - &mocktime_command, - &crash_command, - &restart_command, - &disconnect_command, - &reconnect_command, - &signcommit_command, - &output_command, - &add_route_command, - &routefail_command, + &dev_newhtlc_command, + &dev_fulfillhtlc_command, + &dev_failhtlc_command, + &dev_commit_command, + &dev_feerate_command, + &dev_rhash_command, + &dev_mocktime_command, + &dev_crash_command, + &dev_restart_command, + &dev_disconnect_command, + &dev_reconnect_command, + &dev_signcommit_command, + &dev_output_command, + &dev_add_route_command, + &dev_routefail_command, }; static void json_help(struct command *cmd, diff --git a/daemon/jsonrpc.h b/daemon/jsonrpc.h index bf108cc81..4c5ad6159 100644 --- a/daemon/jsonrpc.h +++ b/daemon/jsonrpc.h @@ -56,28 +56,36 @@ void PRINTF_FMT(2, 3) command_fail(struct command *cmd, const char *fmt, ...); /* For initialization */ void setup_jsonrpc(struct lightningd_state *dstate, const char *rpc_filename); -/* Commands (from other files) */ -extern const struct json_command connect_command; -extern const struct json_command getpeers_command; -extern const struct json_command gethtlcs_command; -extern const struct json_command newhtlc_command; -extern const struct json_command fulfillhtlc_command; -extern const struct json_command failhtlc_command; -extern const struct json_command commit_command; -extern const struct json_command mocktime_command; -extern const struct json_command close_command; +/* Peer management */ extern const struct json_command newaddr_command; -extern const struct json_command reconnect_command; -extern const struct json_command disconnect_command; -extern const struct json_command signcommit_command; -extern const struct json_command output_command; +extern const struct json_command connect_command; +extern const struct json_command close_command; +extern const struct json_command getpeers_command; + +/* Invoice management. */ extern const struct json_command invoice_command; extern const struct json_command listinvoice_command; extern const struct json_command delinvoice_command; extern const struct json_command waitinvoice_command; -extern const struct json_command add_route_command; -extern const struct json_command routefail_command; + +/* Payment management. */ extern const struct json_command getroute_command; extern const struct json_command sendpay_command; -extern const struct json_command feerate_command; + +/* Low-level commands. */ +extern const struct json_command gethtlcs_command; + +/* Developer commands. */ +extern const struct json_command dev_add_route_command; +extern const struct json_command dev_newhtlc_command; +extern const struct json_command dev_fulfillhtlc_command; +extern const struct json_command dev_failhtlc_command; +extern const struct json_command dev_commit_command; +extern const struct json_command dev_mocktime_command; +extern const struct json_command dev_reconnect_command; +extern const struct json_command dev_disconnect_command; +extern const struct json_command dev_signcommit_command; +extern const struct json_command dev_output_command; +extern const struct json_command dev_routefail_command; +extern const struct json_command dev_feerate_command; #endif /* LIGHTNING_DAEMON_JSONRPC_H */ diff --git a/daemon/peer.c b/daemon/peer.c index 6825e35f8..4b70788f3 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -4451,15 +4451,13 @@ static void json_newhtlc(struct command *cmd, command_success(cmd, response); } -/* FIXME: rename to dev- */ -const struct json_command newhtlc_command = { - "newhtlc", +const struct json_command dev_newhtlc_command = { + "dev-newhtlc", json_newhtlc, "Offer {peerid} an HTLC worth {msatoshi} in {expiry} (block number) with {rhash}", "Returns { id: u64 } result on success" }; -/* FIXME: rename to dev- */ static void json_fulfillhtlc(struct command *cmd, const char *buffer, const jsmntok_t *params) { @@ -4555,8 +4553,8 @@ static void json_fulfillhtlc(struct command *cmd, state_name(peer->state)); } -const struct json_command fulfillhtlc_command = { - "fulfillhtlc", +const struct json_command dev_fulfillhtlc_command = { + "dev-fulfillhtlc", json_fulfillhtlc, "Redeem htlc proposed by {peerid} of {id} using {r}", "Returns an empty result on success" @@ -4635,8 +4633,8 @@ static void json_failhtlc(struct command *cmd, state_name(peer->state)); } -const struct json_command failhtlc_command = { - "failhtlc", +const struct json_command dev_failhtlc_command = { + "dev-failhtlc", json_failhtlc, "Fail htlc proposed by {peerid} which has {id}, using {reason}", "Returns an empty result on success" @@ -4679,8 +4677,8 @@ static void json_commit(struct command *cmd, do_commit(peer, cmd); } -const struct json_command commit_command = { - "commit", +const struct json_command dev_commit_command = { + "dev-commit", json_commit, "Commit all staged HTLC changes with {peerid}", "Returns an empty result on success" @@ -4717,7 +4715,7 @@ static void json_close(struct command *cmd, } command_success(cmd, null_response(cmd)); } - + const struct json_command close_command = { "close", json_close, @@ -4747,7 +4745,7 @@ static void json_feerate(struct command *cmd, command_success(cmd, null_response(cmd)); } -const struct json_command feerate_command = { +const struct json_command dev_feerate_command = { "dev-feerate", json_feerate, "Change the (default) fee rate to {feerate}", @@ -4898,28 +4896,28 @@ static void json_output(struct command *cmd, command_success(cmd, null_response(cmd)); } -const struct json_command output_command = { +const struct json_command dev_output_command = { "dev-output", json_output, "Enable/disable any messages to peer {peerid} depending on {enable}", "Returns an empty result on success" }; -const struct json_command disconnect_command = { +const struct json_command dev_disconnect_command = { "dev-disconnect", json_disconnect, "Force a disconnect with peer {peerid}", "Returns an empty result on success" }; -const struct json_command reconnect_command = { +const struct json_command dev_reconnect_command = { "dev-reconnect", json_reconnect, "Force a reconnect with peer {peerid}", "Returns an empty result on success" }; -const struct json_command signcommit_command = { +const struct json_command dev_signcommit_command = { "dev-signcommit", json_signcommit, "Sign and return the current commit with peer {peerid}", diff --git a/daemon/routing.c b/daemon/routing.c index 09c8c40eb..1b63a5669 100644 --- a/daemon/routing.c +++ b/daemon/routing.c @@ -452,8 +452,8 @@ static void json_add_route(struct command *cmd, command_success(cmd, null_response(cmd)); } -const struct json_command add_route_command = { - "add-route", +const struct json_command dev_add_route_command = { + "dev-add-route", json_add_route, "Add route from {src} to {dst}, {base} rate in msatoshi, {var} rate in msatoshi, {delay} blocks delay and {minblocks} minimum timeout", "Returns an empty result on success" @@ -483,7 +483,7 @@ static void json_routefail(struct command *cmd, command_success(cmd, null_response(cmd)); } -const struct json_command routefail_command = { +const struct json_command dev_routefail_command = { "dev-routefail", json_routefail, "FAIL htlcs that we can't route if {enable}", diff --git a/daemon/test/test.sh b/daemon/test/test.sh index fe7fb773d..265b418c2 100755 --- a/daemon/test/test.sh +++ b/daemon/test/test.sh @@ -159,7 +159,7 @@ lcli1() exit 1 fi - if [ "$1" = "newhtlc" ]; then + if [ "$1" = "dev-newhtlc" ]; then # It might have gotten committed, or might be forgotten. ID=`echo "$OUT" | extract_id` if ! htlc_exists "$LCLI1" $2 $ID; then @@ -538,13 +538,13 @@ if [ -n "$DIFFERENT_FEES" ]; then EXPIRY=$(( $(blockheight) + 10)) SECRET=1de08917a61cb2b62ed5937d38577f6a7bfe59c176781c6d8128018e8b5ccdfd RHASH=`lcli1 dev-rhash $SECRET | sed 's/.*"\([0-9a-f]*\)".*/\1/'` - HTLCID=`lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` - [ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 - [ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 + HTLCID=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` + [ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 + [ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 check_status_single lcli2 0 0 "" $(($AMOUNT - $HTLC_AMOUNT - $ONE_HTLCS_FEE2)) $(($ONE_HTLCS_FEE2)) "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH , state : RCVD_ADD_ACK_REVOCATION } " - lcli2 fulfillhtlc $ID1 $HTLCID $SECRET - [ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 - [ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 + lcli2 dev-fulfillhtlc $ID1 $HTLCID $SECRET + [ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 + [ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 check_status_single lcli1 $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) "" $(($HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) "" check_status_single lcli2 $(($HTLC_AMOUNT - $NO_HTLCS_FEE2 / 2)) $(($NO_HTLCS_FEE2 / 2)) "" $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE2 / 2)) $(($NO_HTLCS_FEE2 / 2)) "" @@ -552,8 +552,8 @@ if [ -n "$DIFFERENT_FEES" ]; then # Change fee rate on node2 to same as node1. lcli2 dev-feerate 40000 $CLI generate 1 - [ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 - [ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 + [ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 + [ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 check_status $(($AMOUNT - $HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) "" $(($HTLC_AMOUNT - $NO_HTLCS_FEE / 2)) $(($NO_HTLCS_FEE / 2)) "" @@ -588,14 +588,14 @@ EXPIRY=$(( $(blockheight) + 10)) SECRET=1de08917a61cb2b62ed5937d38577f6a7bfe59c176781c6d8128018e8b5ccdfd RHASH=`lcli1 dev-rhash $SECRET | sed 's/.*"\([0-9a-f]*\)".*/\1/'` -HTLCID=`lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` +HTLCID=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` if [ -n "$MANUALCOMMIT" ]; then # They should register a staged htlc. check_status $A_AMOUNT $A_FEE "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH , state : SENT_ADD_HTLC } " $B_AMOUNT $B_FEE "" # Now commit it. - lcli1 commit $ID2 + lcli1 dev-commit $ID2 # Node 1 hasn't got it committed, but node2 should have told it to stage. check_status_single lcli1 $A_AMOUNT $A_FEE "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH , state : RCVD_ADD_REVOCATION } " $B_AMOUNT $B_FEE "" @@ -618,7 +618,7 @@ if [ -n "$MANUALCOMMIT" ]; then fi # Now node2 gives commitment to node1. - lcli2 commit $ID1 + lcli2 dev-commit $ID1 # After revocation, they should know they're both committed. check lcli1 "getlog debug | $FGREP 'Both committed to ADD of our HTLC'" @@ -676,8 +676,8 @@ if [ -n "$DUMP_ONCHAIN" ]; then all_ok fi -lcli2 fulfillhtlc $ID1 $HTLCID $SECRET -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 +lcli2 dev-fulfillhtlc $ID1 $HTLCID $SECRET +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 # Without manual commit, this check is racy. if [ -n "$MANUALCOMMIT" ]; then @@ -690,7 +690,7 @@ if [ -n "$MANUALCOMMIT" ]; then exit 1 fi fi -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 check lcli1 "getlog debug | $FGREP 'Both committed to FULFILL of our HTLC'" check lcli2 "getlog debug | $FGREP 'Both committed to FULFILL of their HTLC'" @@ -707,18 +707,18 @@ check_status $A_AMOUNT $A_FEE "" $B_AMOUNT $B_FEE "" # A new one, at 10x the amount. HTLC_AMOUNT=100000000 -HTLCID=`lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 +HTLCID=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 # Check channel status A_AMOUNT=$(($A_AMOUNT - $EXTRA_FEE - $HTLC_AMOUNT)) A_FEE=$(($A_FEE + $EXTRA_FEE)) check_status $A_AMOUNT $A_FEE "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH , state : SENT_ADD_ACK_REVOCATION } " $B_AMOUNT $B_FEE "" -lcli2 failhtlc $ID1 $HTLCID 695 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 +lcli2 dev-failhtlc $ID1 $HTLCID 695 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 # Back to how we were before. A_AMOUNT=$(($A_AMOUNT + $EXTRA_FEE + $HTLC_AMOUNT)) @@ -727,9 +727,9 @@ check_status $A_AMOUNT $A_FEE "" $B_AMOUNT $B_FEE "" # Same again, but this time it expires. HTLC_AMOUNT=10000001 -HTLCID=`lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 +HTLCID=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 # Check channel status A_AMOUNT=$(($A_AMOUNT - $EXTRA_FEE - $HTLC_AMOUNT)) @@ -747,8 +747,8 @@ $CLI generate 1 if [ -n "$MANUALCOMMIT" ]; then check_status $A_AMOUNT $A_FEE "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH , state : RCVD_REMOVE_HTLC } " $B_AMOUNT $B_FEE "" - lcli2 commit $ID1 - lcli1 commit $ID2 + lcli2 dev-commit $ID1 + lcli1 dev-commit $ID2 fi # Back to how we were before. @@ -780,15 +780,15 @@ fi # First, give more money to node2, so it can offer HTLCs. EXPIRY=$(( $(blockheight) + 10)) HTLC_AMOUNT=100000000 -HTLCID=`lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 +HTLCID=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 check_status $(($A_AMOUNT - $HTLC_AMOUNT - $EXTRA_FEE)) $(($A_FEE + $EXTRA_FEE)) "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH , state : SENT_ADD_ACK_REVOCATION } " $B_AMOUNT $B_FEE "" -lcli2 fulfillhtlc $ID1 $HTLCID $SECRET -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 +lcli2 dev-fulfillhtlc $ID1 $HTLCID $SECRET +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 # Both now pay equal fees. A_FEE=$(($NO_HTLCS_FEE / 2)) @@ -805,35 +805,35 @@ RHASH2=`lcli1 dev-rhash $SECRET2 | sed 's/.*"\([0-9a-f]*\)".*/\1/'` # This means B will *just* afford it (but can't cover increased fees) HTLC_AMOUNT=$(($B_AMOUNT - $EXTRA_FEE / 2)) -HTLCID=`lcli2 newhtlc $ID1 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` +HTLCID=`lcli2 dev-newhtlc $ID1 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` # Make sure that's committed, in case lcli1 restarts. -lcli2 commit $ID1 >/dev/null || true +lcli2 dev-commit $ID1 >/dev/null || true -HTLCID2=`lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH2 | extract_id` -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 +HTLCID2=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH2 | extract_id` +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 # A covers the extra part of the fee. check_status $(($A_AMOUNT - $HTLC_AMOUNT - $EXTRA_FEE - $EXTRA_FEE / 2)) $(($A_FEE + $EXTRA_FEE + $EXTRA_FEE / 2)) "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH2 , state : SENT_ADD_ACK_REVOCATION } " 0 $(($B_FEE + $EXTRA_FEE / 2)) "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH , state : RCVD_ADD_ACK_REVOCATION } " # Fail both, to reset. -lcli1 failhtlc $ID2 $HTLCID 830 -lcli2 failhtlc $ID1 $HTLCID2 829 +lcli1 dev-failhtlc $ID2 $HTLCID 830 +lcli2 dev-failhtlc $ID1 $HTLCID2 829 -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 check_status $A_AMOUNT $A_FEE "" $B_AMOUNT $B_FEE "" # Now, two HTLCs at once, one from each direction. # Both sides can afford this. HTLC_AMOUNT=1000000 -HTLCID=`lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` -HTLCID2=`lcli2 newhtlc $ID1 $HTLC_AMOUNT $EXPIRY $RHASH2 | extract_id` -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 +HTLCID=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` +HTLCID2=`lcli2 dev-newhtlc $ID1 $HTLC_AMOUNT $EXPIRY $RHASH2 | extract_id` +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 check_status $(($A_AMOUNT - $HTLC_AMOUNT - $EXTRA_FEE)) $(($A_FEE + $EXTRA_FEE)) "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH , state : SENT_ADD_ACK_REVOCATION } " $(($B_AMOUNT - $HTLC_AMOUNT - $EXTRA_FEE)) $(($B_FEE + $EXTRA_FEE)) "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH2 , state : RCVD_ADD_ACK_REVOCATION } " @@ -846,12 +846,12 @@ if [ -n "$CLOSE_WITH_HTLCS" ]; then check_peerstate lcli2 STATE_SHUTDOWN # Fail one, still waiting. - lcli2 failhtlc $ID1 $HTLCID 800 + lcli2 dev-failhtlc $ID1 $HTLCID 800 check_peerstate lcli1 STATE_SHUTDOWN check_peerstate lcli2 STATE_SHUTDOWN # Fulfill the other causes them to actually complete the close. - lcli1 fulfillhtlc $ID2 $HTLCID2 $SECRET2 + lcli1 dev-fulfillhtlc $ID2 $HTLCID2 $SECRET2 check_peerstate lcli1 STATE_MUTUAL_CLOSING check_peerstate lcli2 STATE_MUTUAL_CLOSING @@ -872,11 +872,11 @@ if [ -n "$CLOSE_WITH_HTLCS" ]; then all_ok fi -lcli1 fulfillhtlc $ID2 $HTLCID2 $SECRET2 -lcli2 failhtlc $ID1 $HTLCID 849 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 +lcli1 dev-fulfillhtlc $ID2 $HTLCID2 $SECRET2 +lcli2 dev-failhtlc $ID1 $HTLCID 849 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 # We transferred amount from B to A. A_AMOUNT=$(($A_AMOUNT + $HTLC_AMOUNT)) @@ -886,10 +886,10 @@ check_status $A_AMOUNT $A_FEE "" $B_AMOUNT $B_FEE "" # Now, test making more changes before receiving commit reply. DO_RECONNECT="" lcli2 dev-output $ID1 false -HTLCID=`lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` +HTLCID=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH | extract_id` # Make sure node1 sends commit (in the background, since it will block!) -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 & +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 & if [ -n "$MANUALCOMMIT" ]; then # node2 will consider this committed. @@ -903,12 +903,12 @@ fi check_status_single lcli1 $(($A_AMOUNT)) $(($A_FEE)) "{ msatoshi : $HTLC_AMOUNT, expiry : { block : $EXPIRY }, rhash : $RHASH , state : SENT_ADD_COMMIT } " $B_AMOUNT $B_FEE "" # Now send another offer, and enable node2 output. -HTLCID2=`lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH2 | extract_id` +HTLCID2=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH2 | extract_id` lcli2 dev-output $ID1 true -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 DO_RECONNECT=$RECONNECT @@ -945,11 +945,11 @@ if ! check "$LCLI2 getpeers | tr -s '\012\011\" ' ' ' | fgrep -q 'connected : tr fi # Node2 collects the HTLCs. -lcli2 fulfillhtlc $ID1 $HTLCID $SECRET -lcli2 fulfillhtlc $ID1 $HTLCID2 $SECRET2 +lcli2 dev-fulfillhtlc $ID1 $HTLCID $SECRET +lcli2 dev-fulfillhtlc $ID1 $HTLCID2 $SECRET2 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 # We transferred 2 * amount from A to B. A_AMOUNT=$(($A_AMOUNT - $HTLC_AMOUNT * 2)) @@ -964,12 +964,12 @@ RHASH3=`lcli2 invoice $HTLC_AMOUNT RHASH3 | sed 's/.*"\([0-9a-f]*\)".*/\1/'` lcli2 listinvoice [ "`lcli2 listinvoice | tr -s '\012\011\" ' ' '`" = "{ [ { label : RHASH3 , rhash : $RHASH3 , msatoshi : $HTLC_AMOUNT, complete : false } ] } " ] -HTLCID3=`lcli1 newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH3 | extract_id` -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 +HTLCID3=`lcli1 dev-newhtlc $ID2 $HTLC_AMOUNT $EXPIRY $RHASH3 | extract_id` +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 # We transferred amount from A to B. A_AMOUNT=$(($A_AMOUNT - $HTLC_AMOUNT)) @@ -990,12 +990,12 @@ INVOICES=`lcli2 listinvoice | tr -s '\012\011\" ' ' '` [ "`lcli2 listinvoice RHASH3 | tr -s '\012\011\" ' ' '`" = "{ [ { label : RHASH3 , rhash : $RHASH3 , msatoshi : $HTLC_AMOUNT, complete : true } ] } " ] [ "`lcli2 listinvoice RHASH4 | tr -s '\012\011\" ' ' '`" = "{ [ { label : RHASH4 , rhash : $RHASH4 , msatoshi : $HTLC_AMOUNT, complete : false } ] } " ] -HTLCID4=`lcli1 newhtlc $ID2 $(($HTLC_AMOUNT - 1)) $EXPIRY $RHASH4 | extract_id` -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 +HTLCID4=`lcli1 dev-newhtlc $ID2 $(($HTLC_AMOUNT - 1)) $EXPIRY $RHASH4 | extract_id` +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 -[ ! -n "$MANUALCOMMIT" ] || lcli2 commit $ID1 -[ ! -n "$MANUALCOMMIT" ] || lcli1 commit $ID2 +[ ! -n "$MANUALCOMMIT" ] || lcli2 dev-commit $ID1 +[ ! -n "$MANUALCOMMIT" ] || lcli1 dev-commit $ID2 check lcli2 "getlog | $FGREP 'Short payment for'" check_status $A_AMOUNT $A_FEE "" $B_AMOUNT $B_FEE "" @@ -1026,7 +1026,7 @@ if [ ! -n "$MANUALCOMMIT" ]; then # Tell node 1 about the 2->3 route. # Add to config in case we are restaring. echo "add-route=$ID2/$ID3/546000/10/36/36" >> $DIR1/config - lcli1 add-route $ID2 $ID3 546000 10 36 36 + lcli1 dev-add-route $ID2 $ID3 546000 10 36 36 RHASH5=`lcli3 invoice $HTLC_AMOUNT RHASH5 | sed 's/.*"\([0-9a-f]*\)".*/\1/'` # Get route.