mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-26 17:52:20 +01:00
nip60: expose GetSatoshisAmountFromBolt11() helper.
This commit is contained in:
parent
26da7967dc
commit
0330c198fb
@ -200,7 +200,7 @@ func parseKeysetKeys(keys nut01.KeysMap) (map[uint64]*btcec.PublicKey, error) {
|
||||
return parsedKeys, nil
|
||||
}
|
||||
|
||||
func getSatoshisAmountFromBolt11(bolt11 string) (uint64, error) {
|
||||
func GetSatoshisAmountFromBolt11(bolt11 string) (uint64, error) {
|
||||
if len(bolt11) < 50 {
|
||||
return 0, fmt.Errorf("invalid invoice, too short")
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func TestBolt11Parsing(t *testing.T) {
|
||||
{"lnbc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq", 0, false},
|
||||
} {
|
||||
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 {
|
||||
require.Error(t, err)
|
||||
} else {
|
||||
|
@ -21,7 +21,7 @@ func (w *Wallet) PayBolt11(ctx context.Context, invoice string, opts ...SendOpti
|
||||
opt(ss)
|
||||
}
|
||||
|
||||
invoiceAmount, err := getSatoshisAmountFromBolt11(invoice)
|
||||
invoiceAmount, err := GetSatoshisAmountFromBolt11(invoice)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user