mirror of
https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line.git
synced 2025-06-07 16:06:26 +00:00
Create 16_4_createemptypsbt.c
This commit is contained in:
parent
4ac7c8b67a
commit
293cd0569f
51
src/16_4_createemptypsbt.c
Normal file
51
src/16_4_createemptypsbt.c
Normal file
@ -0,0 +1,51 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "wally_core.h"
|
||||
#include "wally_psbt.h"
|
||||
#include "wally_transaction.h"
|
||||
|
||||
int main(void) {
|
||||
|
||||
int lw_response;
|
||||
struct wally_psbt *psbt;
|
||||
|
||||
char *psbt_64;
|
||||
|
||||
lw_response = wally_psbt_init_alloc(0,1,1,0,&psbt);
|
||||
|
||||
if (lw_response) {
|
||||
|
||||
printf("Error: Wally_psbt_init_alloc failed: %d\n",lw_response);
|
||||
exit(-1);
|
||||
|
||||
}
|
||||
|
||||
struct wally_tx *wtx;
|
||||
lw_response = wally_tx_init_alloc(0,0,1,1,&wtx);
|
||||
|
||||
if (lw_response) {
|
||||
|
||||
printf("Error: Wally_tx_init_alloc failed: %d\n",lw_response);
|
||||
exit(-1);
|
||||
|
||||
}
|
||||
|
||||
lw_response = wally_tx_clone(wtx, 0, &psbt->tx);
|
||||
|
||||
if (lw_response) {
|
||||
|
||||
printf("Error: Wally_tx_clone failed: %d\n",lw_response);
|
||||
exit(-1);
|
||||
|
||||
}
|
||||
|
||||
psbt->num_inputs = wtx->num_inputs;
|
||||
psbt->num_outputs = wtx->num_outputs;
|
||||
wally_tx_free(wtx);
|
||||
|
||||
wally_psbt_to_base64(psbt,0,&psbt_64);
|
||||
printf("%s\n",psbt_64);
|
||||
|
||||
wally_psbt_free(psbt);
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user