MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_transaction_details

Function json_transaction_details

wallet/walletrpc.c:596–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

594};
595
596static void json_transaction_details(struct json_stream *response,
597 const struct wallet_transaction *tx)
598{
599 struct wally_tx *wtx = tx->tx->wtx;
600
601 json_object_start(response, NULL);
602 json_add_txid(response, "hash", &tx->id);
603 json_add_hex_talarr(response, "rawtx", tx->rawtx);
604 json_add_num(response, "blockheight", tx->blockheight);
605 json_add_num(response, "txindex", tx->txindex);
606 json_add_u32(response, "locktime", wtx->locktime);
607 json_add_u32(response, "version", wtx->version);
608
609 json_array_start(response, "inputs");
610 for (size_t i = 0; i < wtx->num_inputs; i++) {
611 struct bitcoin_txid prevtxid;
612 struct wally_tx_input *in = &wtx->inputs[i];
613 bitcoin_tx_input_get_txid(tx->tx, i, &prevtxid);
614
615 json_object_start(response, NULL);
616 json_add_txid(response, "txid", &prevtxid);
617 json_add_u32(response, "index", in->index);
618 json_add_u32(response, "sequence", in->sequence);
619 json_object_end(response);
620 }
621 json_array_end(response);
622
623 json_array_start(response, "outputs");
624 for (size_t i = 0; i < wtx->num_outputs; i++) {
625 struct wally_tx_output *out = &wtx->outputs[i];
626 struct amount_asset amt = bitcoin_tx_output_get_amount(tx->tx, i);
627 struct amount_sat sat;
628
629 /* TODO We should eventually handle non-bitcoin assets as well. */
630 if (amount_asset_is_main(&amt))
631 sat = amount_asset_to_sat(&amt);
632 else
633 sat = AMOUNT_SAT(0);
634
635 json_object_start(response, NULL);
636
637 json_add_u32(response, "index", i);
638 json_add_amount_sat_msat(response, "amount_msat", sat);
639
640 json_add_hex(response, "scriptPubKey", out->script, out->script_len);
641
642 json_object_end(response);
643 }
644 json_array_end(response);
645
646 json_object_end(response);
647}
648
649static struct command_result *json_listtransactions(struct command *cmd,
650 const char *buffer,

Callers 1

json_listtransactionsFunction · 0.85

Calls 14

json_object_startFunction · 0.85
json_add_txidFunction · 0.85
json_add_hex_talarrFunction · 0.85
json_add_numFunction · 0.85
json_add_u32Function · 0.85
json_array_startFunction · 0.85
json_object_endFunction · 0.85
json_array_endFunction · 0.85
json_add_amount_sat_msatFunction · 0.85
json_add_hexFunction · 0.85

Tested by

no test coverage detected