nip60: expose GetSatoshisAmountFromBolt11() helper.

This commit is contained in:
fiatjaf
2025-02-05 13:20:41 -03:00
parent 26da7967dc
commit 0330c198fb
3 changed files with 3 additions and 3 deletions

View File

@@ -200,7 +200,7 @@ func parseKeysetKeys(keys nut01.KeysMap) (map[uint64]*btcec.PublicKey, error) {
return parsedKeys, nil return parsedKeys, nil
} }
func getSatoshisAmountFromBolt11(bolt11 string) (uint64, error) { func GetSatoshisAmountFromBolt11(bolt11 string) (uint64, error) {
if len(bolt11) < 50 { if len(bolt11) < 50 {
return 0, fmt.Errorf("invalid invoice, too short") return 0, fmt.Errorf("invalid invoice, too short")
} }

View File

@@ -25,7 +25,7 @@ func TestBolt11Parsing(t *testing.T) {
{"lnbc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 0, false}, {"lnbc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 0, false},
} { } {
t.Run(fmt.Sprintf("%d = %s", tc.sats, tc.bolt11), func(t *testing.T) { t.Run(fmt.Sprintf("%d = %s", tc.sats, tc.bolt11), func(t *testing.T) {
sats, err := getSatoshisAmountFromBolt11(tc.bolt11) sats, err := GetSatoshisAmountFromBolt11(tc.bolt11)
if tc.hasError { if tc.hasError {
require.Error(t, err) require.Error(t, err)
} else { } else {

View File

@@ -21,7 +21,7 @@ func (w *Wallet) PayBolt11(ctx context.Context, invoice string, opts ...SendOpti
opt(ss) opt(ss)
} }
invoiceAmount, err := getSatoshisAmountFromBolt11(invoice) invoiceAmount, err := GetSatoshisAmountFromBolt11(invoice)
if err != nil { if err != nil {
return "", err return "", err
} }