Skip to content

Commit 3110d20

Browse files
committed
listtransactions: remove annotations
This is a minimal subset of the master commit b8aa3a5 which fixes compile with --enable-experimental-features: ``` wallet/walletrpc.c: In function 'json_transaction_details': wallet/walletrpc.c:521:56: error: 'const struct wallet_transaction' has no member named 'input_annotations' 521 | struct tx_annotation *ann = &tx->input_annotations[i]; | ^~ wallet/walletrpc.c:551:56: error: 'const struct wallet_transaction' has no member named 'output_annotations' 551 | struct tx_annotation *ann = &tx->output_annotations[i]; | ^~ ``` Reported-by: @whitslack Signed-off-by: Rusty Russell <[email protected]> Changelog-Fixed: build: compilation error when `--enable-experimental-features` configured.
1 parent 484d447 commit 3110d20

File tree

2 files changed

+1
-101
lines changed

2 files changed

+1
-101
lines changed

tests/test_wallet.py

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pyln.client import RpcError, Millisatoshi
66
from shutil import copyfile
77
from utils import (
8-
only_one, wait_for, sync_blockheight, EXPERIMENTAL_FEATURES,
8+
only_one, wait_for, sync_blockheight,
99
VALGRIND, check_coin_moves, TailableProc, scriptpubkey_addr,
1010
check_utxos_channel
1111
)
@@ -1065,78 +1065,6 @@ def test_txsend(node_factory, bitcoind, chainparams):
10651065
assert scriptpubkey_addr(decode['vout'][changenum]['scriptPubKey']) in [f['address'] for f in l1.rpc.listfunds()['outputs']]
10661066

10671067

1068-
@unittest.skipIf(TEST_NETWORK != 'regtest', "Fee outputs throw off our output matching logic")
1069-
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "Tests annotations which are compiled only with experimental features")
1070-
def test_transaction_annotations(node_factory, bitcoind):
1071-
l1, l2, l3 = node_factory.get_nodes(3)
1072-
l1.fundwallet(10**6)
1073-
1074-
# We should now have a transaction that gave us the funds in the
1075-
# transactions table...
1076-
outputs = l1.rpc.listfunds()['outputs']
1077-
assert(len(outputs) == 1 and outputs[0]['status'] == 'confirmed')
1078-
out = outputs[0]
1079-
idx = out['output']
1080-
assert(idx in [0, 1] and out['amount_msat'] == Millisatoshi("{}sat".format(10**6)))
1081-
1082-
# ... and it should have an annotation on the output reading 'deposit'
1083-
txs = l1.rpc.listtransactions()['transactions']
1084-
assert(len(txs) == 1)
1085-
tx = txs[0]
1086-
output = tx['outputs'][idx]
1087-
assert(output['type'] == 'deposit' and output['amount_msat'] == Millisatoshi(1000000000))
1088-
1089-
# ... and all other output should be change, and have no annotations
1090-
types = []
1091-
for i, o in enumerate(tx['outputs']):
1092-
if i == idx:
1093-
continue
1094-
if 'type' in o:
1095-
types.append(o['type'])
1096-
else:
1097-
types.append(None)
1098-
1099-
assert(set([None]) == set(types))
1100-
1101-
##########################################################################
1102-
# Let's now open a channel. The opener should get the funding transaction
1103-
# annotated as channel open and deposit.
1104-
l1.connect(l2)
1105-
fundingtx = l1.rpc.fundchannel(l2.info['id'], 10**5)
1106-
1107-
# We should have one output unreserved, and it should be unconfirmed
1108-
outputs = l1.rpc.listfunds()['outputs']
1109-
assert len(outputs) == 2
1110-
outputs = [o for o in outputs if not o['reserved']]
1111-
assert(len(outputs) == 1 and outputs[0]['status'] == 'unconfirmed')
1112-
1113-
# It should also match the funding txid:
1114-
assert(outputs[0]['txid'] == fundingtx['txid'])
1115-
1116-
# Confirm the channel and check that the output changed to confirmed
1117-
bitcoind.generate_block(3)
1118-
sync_blockheight(bitcoind, [l1, l2])
1119-
outputs = l1.rpc.listfunds()['outputs']
1120-
assert(len(outputs) == 1 and outputs[0]['status'] == 'confirmed')
1121-
1122-
# We should have 2 transactions, the second one should be the funding tx
1123-
# (we are ordering by blockheight and txindex, so that order should be ok)
1124-
txs = l1.rpc.listtransactions()['transactions']
1125-
assert(len(txs) == 2 and txs[1]['hash'] == fundingtx['txid'])
1126-
1127-
# Check the annotated types
1128-
types = [o['type'] for o in txs[1]['outputs']]
1129-
changeidx = 0 if types[0] == 'deposit' else 1
1130-
fundidx = 1 - changeidx
1131-
assert(types[changeidx] == 'deposit' and types[fundidx] == 'channel_funding')
1132-
1133-
# And check the channel annotation on the funding output
1134-
channels = l1.rpc.listpeerchannels()['channels']
1135-
assert(len(channels) == 1)
1136-
scid = channels[0]['short_channel_id']
1137-
assert(txs[1]['outputs'][fundidx]['channel'] == scid)
1138-
1139-
11401068
def write_all(fd, bytestr):
11411069
"""Wrapper, since os.write can do partial writes"""
11421070
off = 0

wallet/walletrpc.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -484,16 +484,6 @@ struct {
484484
{TX_CHANNEL_CHEAT, "channel_unilateral_cheat"},
485485
};
486486

487-
#if EXPERIMENTAL_FEATURES
488-
static const char *txtype_to_string(enum wallet_tx_type t)
489-
{
490-
for (size_t i = 0; i < ARRAY_SIZE(wallet_tx_type_display_names); i++)
491-
if (t == wallet_tx_type_display_names[i].t)
492-
return wallet_tx_type_display_names[i].name;
493-
return NULL;
494-
}
495-
#endif
496-
497487
static void json_transaction_details(struct json_stream *response,
498488
const struct wallet_transaction *tx)
499489
{
@@ -517,15 +507,6 @@ static void json_transaction_details(struct json_stream *response,
517507
json_add_txid(response, "txid", &prevtxid);
518508
json_add_u32(response, "index", in->index);
519509
json_add_u32(response, "sequence", in->sequence);
520-
#if EXPERIMENTAL_FEATURES
521-
struct tx_annotation *ann = &tx->input_annotations[i];
522-
const char *txtype = txtype_to_string(ann->type);
523-
if (txtype != NULL)
524-
json_add_string(response, "type", txtype);
525-
if (ann->channel.u64 != 0)
526-
json_add_short_channel_id(response, "channel", &ann->channel);
527-
#endif
528-
529510
json_object_end(response);
530511
}
531512
json_array_end(response);
@@ -547,15 +528,6 @@ static void json_transaction_details(struct json_stream *response,
547528
json_add_u32(response, "index", i);
548529
json_add_amount_sat_msat(response, "amount_msat", sat);
549530

550-
#if EXPERIMENTAL_FEATURES
551-
struct tx_annotation *ann = &tx->output_annotations[i];
552-
const char *txtype = txtype_to_string(ann->type);
553-
if (txtype != NULL)
554-
json_add_string(response, "type", txtype);
555-
556-
if (ann->channel.u64 != 0)
557-
json_add_short_channel_id(response, "channel", &ann->channel);
558-
#endif
559531
json_add_hex(response, "scriptPubKey", out->script, out->script_len);
560532

561533
json_object_end(response);

0 commit comments

Comments
 (0)