Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

funding amount max limitation #1636

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ln/ln_funding_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
**************************************************************************/

#define LN_FUNDING_SATOSHIS_MIN (100000) ///< minimum funding_sat(BOLTに規定はない)
#define LN_FUNDING_SATOSHIS_MAX (0x1000000 - 1) //2^24-1
//#define LN_FUNDING_SATOSHIS_MAX (0x1000000 - 1) //2^24-1
#define LN_FUNDING_SATOSHIS_MAX (5000000) ///< maximum funding_sat


#define LN_FUNDING_ROLE_FUNDEE (0x00)
Expand Down
13 changes: 11 additions & 2 deletions ptarmcli/ptarmcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,21 @@ static void optfunc_funding(int *pOption, bool *pConn)
funding_conf_t fundconf;

conf_funding_init(&fundconf);
const char *p_error_str = "funding";
const char *param = strtok(optarg, ",");
char *endp = NULL;
fundconf.funding_sat = (uint64_t)strtoul(param, &endp, 10);
if ((endp != NULL) && (*endp != 0x00)) {
//変換失敗
LOGE("fail: *endp = %p(%02x)\n", endp, *endp);
} else {
bret = true;
if ( (fundconf.funding_sat >= LN_FUNDING_SATOSHIS_MIN) &&
(fundconf.funding_sat <= LN_FUNDING_SATOSHIS_MAX) ) {
bret = true;
} else {
snprintf(mErrStr, sizeof(mErrStr), "funding satoshis is out of range(%d - %d)", LN_FUNDING_SATOSHIS_MIN, LN_FUNDING_SATOSHIS_MAX);
p_error_str = NULL;
}
}
if (bret) {
param = strtok(NULL, ",");
Expand Down Expand Up @@ -647,7 +654,9 @@ static void optfunc_funding(int *pOption, bool *pConn)
*pConn = false;
*pOption = M_OPT_FUND;
} else {
strcpy(mErrStr, "funding");
if (p_error_str != NULL) {
strcpy(mErrStr, p_error_str);
}
*pOption = M_OPTIONS_ERR;
}
}
Expand Down