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

and then use it to print out things
This commit is contained in:
niftynei
2020-07-02 15:53:51 -05:00
committed by Rusty Russell
parent 4ecbd5f1a7
commit 14de198bd1
3 changed files with 13 additions and 2 deletions

View File

@@ -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)

View File

@@ -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) \

View File

@@ -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)));
}
}