Browse Source

wally-tx: add type-to-string for a wally-tx

and then use it to print out things
paymod-04
niftynei 4 years ago
committed by Rusty Russell
parent
commit
14de198bd1
  1. 9
      bitcoin/tx.c
  2. 1
      common/type_to_string.h
  3. 5
      wallet/walletrpc.c

9
bitcoin/tx.c

@ -632,8 +632,17 @@ static char *fmt_bitcoin_txid(const tal_t *ctx, const struct bitcoin_txid *txid)
return hexstr;
}
static char *fmt_wally_tx(const tal_t *ctx, const struct wally_tx *tx)
{
u8 *lin = linearize_wtx(ctx, tx);
char *s = tal_hex(ctx, lin);
tal_free(lin);
return s;
}
REGISTER_TYPE_TO_STRING(bitcoin_tx, fmt_bitcoin_tx);
REGISTER_TYPE_TO_STRING(bitcoin_txid, fmt_bitcoin_txid);
REGISTER_TYPE_TO_STRING(wally_tx, fmt_wally_tx);
void fromwire_bitcoin_txid(const u8 **cursor, size_t *max,
struct bitcoin_txid *txid)

1
common/type_to_string.h

@ -37,6 +37,7 @@ union printable_types {
const struct fee_states *fee_states;
const char *charp_;
const struct wally_psbt *wally_psbt;
const struct wally_tx *wally_tx;
};
#define type_to_string(ctx, type, ptr) \

5
wallet/walletrpc.c

@ -99,8 +99,9 @@ static void wallet_withdrawal_broadcast(struct bitcoind *bitcoind UNUSED,
was_pending(command_success(cmd, response));
} else {
was_pending(command_fail(cmd, LIGHTNINGD,
"Error broadcasting transaction: %s. Unsent tx discarded",
output));
"Error broadcasting transaction: %s. Unsent tx discarded %s",
output,
type_to_string(tmpctx, struct wally_tx, txb->wtx)));
}
}

Loading…
Cancel
Save