Browse Source

psbt-json: remove reliance on bitcoin_tx, use straight wally_psbt struct

paymod-01
niftynei 5 years ago
committed by Christian Decker
parent
commit
85dca84327
  1. 5
      bitcoin/tx.c
  2. 5
      bitcoin/tx.h
  3. 5
      common/json_helpers.c
  4. 2
      common/json_helpers.h
  5. 2
      wallet/walletrpc.c

5
bitcoin/tx.c

@ -494,11 +494,6 @@ void bitcoin_tx_finalize(struct bitcoin_tx *tx)
assert(bitcoin_tx_check(tx));
}
char *bitcoin_tx_to_psbt_base64(const tal_t *ctx, struct bitcoin_tx *tx)
{
return psbt_to_b64(ctx, tx->psbt);
}
struct bitcoin_tx *bitcoin_tx_with_psbt(const tal_t *ctx, struct wally_psbt *psbt STEALS)
{
struct bitcoin_tx *tx = bitcoin_tx(ctx, chainparams,

5
bitcoin/tx.h

@ -220,10 +220,5 @@ void towire_bitcoin_txid(u8 **pptr, const struct bitcoin_txid *txid);
void towire_bitcoin_tx(u8 **pptr, const struct bitcoin_tx *tx);
void towire_bitcoin_tx_output(u8 **pptr, const struct bitcoin_tx_output *output);
/*
* Get the base64 string encoded PSBT of a bitcoin transaction.
*/
char *bitcoin_tx_to_psbt_base64(const tal_t *ctx, struct bitcoin_tx *tx);
int wally_tx_clone(struct wally_tx *tx, struct wally_tx **output);
#endif /* LIGHTNING_BITCOIN_TX_H */

5
common/json_helpers.c

@ -1,6 +1,7 @@
#include <arpa/inet.h>
#include <bitcoin/preimage.h>
#include <bitcoin/privkey.h>
#include <bitcoin/psbt.h>
#include <bitcoin/pubkey.h>
#include <bitcoin/short_channel_id.h>
#include <ccan/ccan/str/hex/hex.h>
@ -242,10 +243,10 @@ void json_add_tx(struct json_stream *result,
void json_add_psbt(struct json_stream *stream,
const char *fieldname,
struct bitcoin_tx *tx)
struct wally_psbt *psbt)
{
const char *psbt_b64;
psbt_b64 = bitcoin_tx_to_psbt_base64(tx, tx);
psbt_b64 = psbt_to_b64(NULL, psbt);
json_add_string(stream, fieldname, take(psbt_b64));
}

2
common/json_helpers.h

@ -141,6 +141,6 @@ void json_add_tx(struct json_stream *result,
/* '"fieldname" : "cHNidP8BAJoCAAAAAljo..." or "cHNidP8BAJoCAAAAAljo..." if fieldname is NULL */
void json_add_psbt(struct json_stream *stream,
const char *fieldname,
struct bitcoin_tx *tx);
struct wally_psbt *psbt);
#endif /* LIGHTNING_COMMON_JSON_HELPERS_H */

2
wallet/walletrpc.c

@ -442,7 +442,7 @@ static struct command_result *json_txprepare(struct command *cmd,
response = json_stream_success(cmd);
json_add_tx(response, "unsigned_tx", utx->tx);
json_add_txid(response, "txid", &utx->txid);
json_add_psbt(response, "psbt", utx->tx);
json_add_psbt(response, "psbt", utx->tx->psbt);
return command_success(cmd, response);
}
static const struct json_command txprepare_command = {

Loading…
Cancel
Save