bitcoin/script.c: Add scriptpubkey_opreturn_padded, which creates an OP_RETURN with a pointless random 20-byte padding.

In the case of `donateutxo`, this is needed since a simple spend of a P2WPKH to an `OP_RETURN` would be below the minimum transaction size.
Sizes below 20 are not plausible as commitments.
This commit is contained in:
ZmnSCPxj jxPCSnmZ
2020-09-08 12:52:41 +09:30
committed by Rusty Russell
parent ee276bcb86
commit 6c13e9b300
2 changed files with 16 additions and 0 deletions

View File

@@ -30,6 +30,11 @@ u8 *scriptpubkey_p2pkh(const tal_t *ctx, const struct bitcoin_address *addr);
/* Create a prunable output script */
u8 *scriptpubkey_opreturn(const tal_t *ctx);
/* Create a prunable output script with 20 random bytes.
* This is needed since a spend from a p2wpkh to an `OP_RETURN` without
* any other outputs would result in a transaction smaller than the
* minimum size. */
u8 *scriptpubkey_opreturn_padded(const tal_t *ctx);
/* Create an input script which spends p2pkh */
u8 *bitcoin_redeem_p2pkh(const tal_t *ctx, const struct pubkey *pubkey,