@ -470,126 +470,6 @@ create_tx:
return NULL ;
return NULL ;
}
}
static struct command_result * json_txprepare ( struct command * cmd ,
const char * buffer ,
const jsmntok_t * obj UNNEEDED ,
const jsmntok_t * params )
{
struct unreleased_tx * utx ;
struct command_result * res ;
struct json_stream * response ;
res = json_prepare_tx ( cmd , buffer , params , false , & utx , NULL ) ;
if ( res )
return res ;
/* utx will persist past this command. */
tal_steal ( cmd - > ld - > wallet , utx ) ;
add_unreleased_tx ( cmd - > ld - > wallet , utx ) ;
response = json_stream_success ( cmd ) ;
json_add_tx ( response , " unsigned_tx " , utx - > tx ) ;
json_add_txid ( response , " txid " , & utx - > txid ) ;
return command_success ( cmd , response ) ;
}
static const struct json_command txprepare_command = {
" txprepare " ,
" bitcoin " ,
json_txprepare ,
" Create a transaction, with option to spend in future (either txsend and txdiscard) " ,
false
} ;
AUTODATA ( json_command , & txprepare_command ) ;
static struct command_result * param_unreleased_txid ( struct command * cmd ,
const char * name ,
const char * buffer ,
const jsmntok_t * tok ,
struct unreleased_tx * * utx )
{
struct command_result * res ;
struct bitcoin_txid * txid ;
res = param_txid ( cmd , name , buffer , tok , & txid ) ;
if ( res )
return res ;
* utx = find_unreleased_tx ( cmd - > ld - > wallet , txid ) ;
if ( ! * utx )
return command_fail ( cmd , LIGHTNINGD ,
" %s not an unreleased txid " ,
type_to_string ( cmd , struct bitcoin_txid ,
txid ) ) ;
tal_free ( txid ) ;
return NULL ;
}
static struct command_result * json_txsend ( struct command * cmd ,
const char * buffer ,
const jsmntok_t * obj UNNEEDED ,
const jsmntok_t * params )
{
struct unreleased_tx * utx ;
if ( ! param ( cmd , buffer , params ,
p_req ( " txid " , param_unreleased_txid , & utx ) ,
NULL ) )
return command_param_failed ( ) ;
/* We delete from list now, and this command owns it. */
remove_unreleased_tx ( utx ) ;
tal_steal ( cmd , utx ) ;
/* We're the owning cmd now. */
utx - > wtx - > cmd = cmd ;
wallet_transaction_add ( cmd - > ld - > wallet , utx - > tx - > wtx , 0 , 0 ) ;
wallet_transaction_annotate ( cmd - > ld - > wallet , & utx - > txid ,
TX_UNKNOWN , 0 ) ;
return broadcast_and_wait ( cmd , utx ) ;
}
static const struct json_command txsend_command = {
" txsend " ,
" bitcoin " ,
json_txsend ,
" Sign and broadcast a transaction created by txprepare " ,
false
} ;
AUTODATA ( json_command , & txsend_command ) ;
static struct command_result * json_txdiscard ( struct command * cmd ,
const char * buffer ,
const jsmntok_t * obj UNNEEDED ,
const jsmntok_t * params )
{
struct unreleased_tx * utx ;
struct json_stream * response ;
if ( ! param ( cmd , buffer , params ,
p_req ( " txid " , param_unreleased_txid , & utx ) ,
NULL ) )
return command_param_failed ( ) ;
/* Free utx with this command */
tal_steal ( cmd , utx ) ;
response = json_stream_success ( cmd ) ;
json_add_tx ( response , " unsigned_tx " , utx - > tx ) ;
json_add_txid ( response , " txid " , & utx - > txid ) ;
return command_success ( cmd , response ) ;
}
static const struct json_command txdiscard_command = {
" txdiscard " ,
" bitcoin " ,
json_txdiscard ,
" Abandon a transaction created by txprepare " ,
false
} ;
AUTODATA ( json_command , & txdiscard_command ) ;
/**
/**
* json_withdraw - Entrypoint for the withdrawal flow
* json_withdraw - Entrypoint for the withdrawal flow
*
*