Example #1
0
char *_submit_withdraw(struct ramchain_info *ram,struct cointx_info *cointx,char *othersignedtx)
{
    FILE *fp;
    char fname[512],*cointxid,*signed2transaction;
    if ( ram->S.gatewayid < 0 )
        return(0);
    if ( cosigntransaction(&cointxid,&signed2transaction,ram->name,ram->serverport,ram->userpass,cointx,othersignedtx,ram->S.gatewayid,NUM_GATEWAYS) > 0 )
    {
        if ( signed2transaction != 0 && signed2transaction[0] != 0 )
        {
            if ( cointxid != 0 && cointxid[0] != 0 )
            {
                sprintf(fname,"%s/%s.%s",ram->backups,cointxid,ram->name);
                if ( (fp= fopen(os_compatible_path(fname),"w")) != 0 )
                {
                    fprintf(fp,"%s\n",signed2transaction);
                    fclose(fp);
                    printf("wrote.(%s) to file.(%s)\n",signed2transaction,fname);
                }
                else printf("unexpected %s cointxid.%s already there before submit??\n",ram->name,cointxid);
                printf("rawtxid len.%ld submitted.%s\n",strlen(signed2transaction),cointxid);
                free(signed2transaction);
                return(clonestr(cointxid));
            } else printf("error null cointxid\n");
        } else printf("error submit raw.%s\n",signed2transaction);
    }
    return(0);
}
Example #2
0
void ensure_directory(char *dirname)
{
    FILE *fp;
    if ( (fp= fopen(os_compatible_path(dirname),"rb")) == 0 )
        mkdir(dirname,511);
    else fclose(fp);
}
Example #3
0
void ensure_directory(char *dirname)
{
    FILE *fp;
    if ( (fp= fopen(os_compatible_path(dirname),"rb")) == 0 )
#ifndef _WIN32
        mkdir(dirname,511);
#else
        mkdir(dirname);
#endif
    else fclose(fp);
Example #4
0
uint16_t extract_userpass(char *serverport,char *userpass,char *coinstr,char *userhome,char *coindir,char *confname)
{
    FILE *fp; uint16_t port = 0;
    char fname[2048],line[1024],*rpcuser,*rpcpassword,*rpcport,*str;
    if ( strcmp(coinstr,"NXT") == 0 )
        return(0);
    serverport[0] = userpass[0] = 0;
    set_coinconfname(fname,coinstr,userhome,coindir,confname);
    printf("set_coinconfname.(%s)\n",fname);
    if ( (fp= fopen(os_compatible_path(fname),"r")) != 0 )
    {
        if ( Debuglevel > 1 )
            printf("extract_userpass from (%s)\n",fname);
        rpcuser = rpcpassword = rpcport = 0;
        while ( fgets(line,sizeof(line),fp) != 0 )
        {
            if ( line[0] == '#' )
                continue;
            //printf("line.(%s) %p %p\n",line,strstr(line,"rpcuser"),strstr(line,"rpcpassword"));
            if ( (str= strstr(line,"rpcuser")) != 0 )
                rpcuser = parse_conf_line(str,"rpcuser");
            else if ( (str= strstr(line,"rpcpassword")) != 0 )
                rpcpassword = parse_conf_line(str,"rpcpassword");
            else if ( (str= strstr(line,"rpcport")) != 0 )
                rpcport = parse_conf_line(str,"rpcport");
        }
        if ( rpcuser != 0 && rpcpassword != 0 )
        {
            if ( userpass[0] == 0 )
                sprintf(userpass,"%s:%s",rpcuser,rpcpassword);
        }
        if ( rpcport != 0 )
        {
            port = myatoi(rpcport,65536);
            if ( serverport[0] == 0 )
                sprintf(serverport,"127.0.0.1:%s",rpcport);
            free(rpcport);
        }
        if ( Debuglevel > 1 )
            printf("-> (%s):(%s) userpass.(%s) serverport.(%s)\n",rpcuser,rpcpassword,userpass,serverport);
        if ( rpcuser != 0 )
            free(rpcuser);
        if ( rpcpassword != 0 )
            free(rpcpassword);
        fclose(fp);
    } else printf("extract_userpass cant open.(%s)\n",fname);
    return(port);
}
Example #5
0
int32_t setnxturl(struct destbuf *urlbuf)
{
    FILE *fp; cJSON *json; char confname[512],buf[65536];
    strcpy(confname,"../../SuperNET.conf"), os_compatible_path(confname);
    urlbuf->buf[0] = 0;
    if ( (fp= fopen(confname,"rb")) != 0 )
    {
        if ( fread(buf,1,sizeof(buf),fp) > 0 )
        {
            if ( (json= cJSON_Parse(buf)) != 0 )
            {
                copy_cJSON(urlbuf,cJSON_GetObjectItem(json,"NXTAPIURL"));
fprintf(stderr,"set NXTAPIURL.(%s)\n",urlbuf->buf);
                free_json(json);
            } else fprintf(stderr,"setnxturl parse error.(%s)\n",buf);
        } else fprintf(stderr,"setnxturl error reading.(%s)\n",confname);
        fclose(fp);
    } else fprintf(stderr,"setnxturl cant open.(%s)\n",confname);
    return((int32_t)strlen(urlbuf->buf));
}