Skip to content

Commit

Permalink
revert gro to satoshi for compatibility with grspay/spark
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Dec 19, 2018
1 parent 6558041 commit 09de190
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Let's assume the **remote** node is accepting connections at `<ip>`

```
cli/lightning-cli connect <node_id> <ip> [<port>]
cli/lightning-cli fundchannel <node_id> <amount_in_gro>
cli/lightning-cli fundchannel <node_id> <amount_in_satoshis>
```

This opens a connection and, on top of that connection, then opens
Expand Down Expand Up @@ -211,7 +211,7 @@ lightningd/lightningd --help
## Further information

### Developers
Developers wishing to contribute should start with the developer guide [here](doc/HACKING.md).
Developers wishing to contribute should start with the developer guide [here](doc/HACKING.md).


### JSON RPC
Expand Down
6 changes: 3 additions & 3 deletions contrib/pylightning/lightning-pay
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from lightning import LightningRpc

parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("bolt11_or_destination_id")
parser.add_argument("amount_in_milli_gro", default=None, type=int, nargs="?")
parser.add_argument("amount_in_milli_satoshi", default=None, type=int, nargs="?")
parser.add_argument("payment_hash", nargs="?")
parser.add_argument("min_final_cltv_expiry", nargs="?")
args = parser.parse_args()
Expand Down Expand Up @@ -38,7 +38,7 @@ if use_bolt11:
amount_included_in_bolt = True
amount = bolt11["msatoshi"]
else:
assert args.amount_in_milli_satoshi, "need argument amount_in_milli_gro"
assert args.amount_in_milli_satoshi, "need argument amount_in_milli_satoshi"
amount = args.amount_in_milli_satoshi
amount_included_in_bolt = False

Expand All @@ -53,7 +53,7 @@ if use_bolt11:
print("Not sending.")

else:
assert args.amount_in_milli_satoshi, "need argument amount_in_milli_gro"
assert args.amount_in_milli_satoshi, "need argument amount_in_milli_satoshi"
assert args.payment_hash, "need argument payment_hash"
assert args.min_final_cltv_expiry, "need argument min_final_cltv_expiry"
amount = args.amount_in_milli_satoshi
Expand Down
8 changes: 4 additions & 4 deletions contrib/pylightning/lightning/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,13 @@ def listpeers(self, peerid=None, level=None):

def fundchannel(self, node_id, satoshi, feerate=None, announce=True):
"""
Fund channel with {id} using {gro} gro's
Fund channel with {id} using {satoshi} satoshis
with feerate of {feerate} (uses default feerate if unset).
If {announce} is False, don't send channel announcements.
"""
payload = {
"id": node_id,
"gro": satoshi,
"satoshi": satoshi,
"feerate": feerate,
"announce": announce
}
Expand Down Expand Up @@ -440,12 +440,12 @@ def dev_memleak(self):

def withdraw(self, destination, satoshi, feerate=None):
"""
Send to {destination} address {gro} (or "all")
Send to {destination} address {satoshi} (or "all")
amount via Groestlcoin transaction
"""
payload = {
"destination": destination,
"gro": satoshi,
"satoshi": satoshi,
"feerate": feerate
}
return self.call("withdraw", payload)
Expand Down
2 changes: 1 addition & 1 deletion lightningd/chaintopology.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ static void json_feerates(struct command *cmd,
static const struct json_command feerates_command = {
"feerates",
json_feerates,
"Return feerate estimates, either gro-per-kw ({style} perkw) or gro-per-kb ({style} perkb)."
"Return feerate estimates, either satoshi-per-kw ({style} perkw) or satoshi-per-kb ({style} perkb)."
};
AUTODATA(json_command, &feerates_command);

Expand Down
2 changes: 1 addition & 1 deletion lightningd/jsonrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ bool json_tok_wtx(struct wallet_tx * tx, const char * buffer,
tx->amount = max;
} else if (!json_to_u64(buffer, sattok, &tx->amount)) {
command_fail(tx->cmd, JSONRPC2_INVALID_PARAMS,
"Invalid gro's");
"Invalid satoshis");
return false;
} else if (tx->amount > max) {
command_fail(tx->cmd, FUND_MAX_EXCEEDED,
Expand Down
4 changes: 2 additions & 2 deletions lightningd/opening_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ static void json_fund_channel(struct command *cmd,
wtx_init(cmd, &fc->wtx);
if (!param(fc->cmd, buffer, params,
p_req("id", json_tok_pubkey, &id),
p_req("gro", json_tok_tok, &sattok),
p_req("satoshi", json_tok_tok, &sattok),
p_opt("feerate", json_tok_feerate, &feerate_per_kw),
p_opt_def("announce", json_tok_bool, &announce_channel, true),
NULL))
Expand Down Expand Up @@ -865,7 +865,7 @@ static void json_fund_channel(struct command *cmd,
static const struct json_command fund_channel_command = {
"fundchannel",
json_fund_channel,
"Fund channel with {id} using {gro} (or 'all') gro's, at optional {feerate}"
"Fund channel with {id} using {satoshi} (or 'all') satoshis, at optional {feerate}"
};
AUTODATA(json_command, &fund_channel_command);

Expand Down
2 changes: 1 addition & 1 deletion lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ static void config_register_opts(struct lightningd *ld)
&ld->config.rescan,
"Number of blocks to rescan from the current head, or "
"absolute blockheight if negative");
opt_register_arg("--fee-per-gro", opt_set_s32, opt_show_s32,
opt_register_arg("--fee-per-satoshi", opt_set_s32, opt_show_s32,
&ld->config.fee_per_satoshi,
"Microgro fee for every gro in HTLC");
opt_register_arg("--addr", opt_add_addr, NULL,
Expand Down
6 changes: 3 additions & 3 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ static void json_add_peer(struct lightningd *ld,
channel->funding_satoshi * 1000);

/* channel config */
json_add_u64(response, "dust_limit_gro",
json_add_u64(response, "dust_limit_satoshis",
channel->our_config.dust_limit_satoshis);
json_add_u64(response, "max_htlc_value_in_flight_msat",
channel->our_config.max_htlc_value_in_flight_msat);
Expand All @@ -734,9 +734,9 @@ static void json_add_peer(struct lightningd *ld,
* is imposed on their side, while their
* configuration `channel_reserve_satoshis` is
* imposed on ours. */
json_add_u64(response, "their_channel_reserve_gro",
json_add_u64(response, "their_channel_reserve_satoshis",
channel->our_config.channel_reserve_satoshis);
json_add_u64(response, "our_channel_reserve_gro",
json_add_u64(response, "our_channel_reserve_satoshis",
channel->channel_info.their_config.channel_reserve_satoshis);
/* Compute how much we can send via this channel. */
if (channel->our_msatoshi <= our_reserve_msat)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def test_reconnect_receiver_add(node_factory):
rhash = l2.rpc.invoice(amt, 'testpayment2', 'desc')['payment_hash']
assert only_one(l2.rpc.listinvoices('testpayment2')['invoices'])['status'] == 'unpaid'

route = [{'gro': amt, 'id': l2.info['id'], 'delay': 5, 'channel': '1:1:1'}]
route = [{'msatoshi': amt, 'id': l2.info['id'], 'delay': 5, 'channel': '1:1:1'}]
l1.rpc.sendpay(route, rhash)
for i in range(len(disconnects)):
l1.daemon.wait_for_log('Already have funding locked in')
Expand Down Expand Up @@ -618,7 +618,7 @@ def test_funding_all_too_much(node_factory):
l1.rpc.fundchannel(l2.info['id'], "all")
l1.bitcoin.rpc.generate(10)
assert only_one(l1.rpc.listfunds()['outputs'])['status'] == 'unconfirmed'
assert only_one(l1.rpc.listfunds()['channels'])['channel_total_gro'] == 2**24 - 1
assert only_one(l1.rpc.listfunds()['channels'])['channel_total_sat'] == 2**24 - 1


def test_funding_fail(node_factory, bitcoind):
Expand Down
10 changes: 5 additions & 5 deletions wallet/walletrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static void json_withdraw(struct command *cmd,

if (!param(cmd, buffer, params,
p_req("destination", json_tok_tok, &desttok),
p_req("gro", json_tok_tok, &sattok),
p_req("satoshi", json_tok_tok, &sattok),
p_opt("feerate", json_tok_feerate, &feerate_per_kw),
NULL))
return;
Expand Down Expand Up @@ -165,8 +165,8 @@ static void json_withdraw(struct command *cmd,
static const struct json_command withdraw_command = {
"withdraw",
json_withdraw,
"Send to {destination} address {gro} (or 'all') amount via Groestlcoin transaction, at optional {feerate}",
false, "Send funds from the internal wallet to the specified address. Either specify a number of gro's to send or 'all' to sweep all funds in the internal wallet to the address."
"Send to {destination} address {satoshi} (or 'all') amount via Groestlcoin transaction, at optional {feerate}",
false, "Send funds from the internal wallet to the specified address. Either specify a number of satoshis to send or 'all' to sweep all funds in the internal wallet to the address."
};
AUTODATA(json_command, &withdraw_command);

Expand Down Expand Up @@ -446,9 +446,9 @@ static void json_listfunds(struct command *cmd,
c->scid);

/* Poor man's rounding to satoshis to match the unit for outputs */
json_add_u64(response, "channel_gro",
json_add_u64(response, "channel_sat",
(c->our_msatoshi + 500)/1000);
json_add_u64(response, "channel_total_gro",
json_add_u64(response, "channel_total_sat",
c->funding_satoshi);
json_add_txid(response, "funding_txid",
&c->funding_txid);
Expand Down

0 comments on commit 09de190

Please sign in to comment.