File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ package common
16
16
17
17
import (
18
18
"fmt"
19
+ "strings"
19
20
20
21
"github.com/blinklabs-io/gouroboros/base58"
21
22
"github.com/blinklabs-io/gouroboros/bech32"
@@ -55,6 +56,7 @@ type Address struct {
55
56
56
57
// NewAddress returns an Address based on the provided bech32 address string
57
58
func NewAddress (addr string ) (Address , error ) {
59
+ addr = strings .ToLower (addr )
58
60
_ , data , err := bech32 .DecodeNoLimit (addr )
59
61
if err != nil {
60
62
return Address {}, err
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import (
18
18
"testing"
19
19
20
20
"github.com/blinklabs-io/gouroboros/internal/test"
21
+ "github.com/stretchr/testify/assert"
21
22
)
22
23
23
24
func TestAddressFromBytes (t * testing.T ) {
@@ -225,3 +226,13 @@ func TestAddressStakeAddress(t *testing.T) {
225
226
}
226
227
}
227
228
}
229
+
230
+ func TestAddressPaymentAddress_MixedCase (t * testing.T ) {
231
+
232
+ // address: "addr_test1qqawz5hm2tchtmarkfn2tamzvd2spatl89gtutgra6zwc3ktqj7p944ckc9lq7u36jrq99znwhzlq6jfv2j4ql92m4rq07hp8t",
233
+ // address with mixed case
234
+ mixedCaseAddress := "addr_test1QQawz5hm2tchtmarkfn2tamzvd2spatl89gtutgra6zwc3ktqj7p944ckc9lq7u36jrq99znwhzlq6jfv2j4ql92m4rq07hp8t"
235
+ addr , err := NewAddress (mixedCaseAddress )
236
+ assert .Nil (t , err , "Expected no error when decoding a mixed-case address" )
237
+ assert .NotNil (t , addr , "Expected a valid address object after decoding" )
238
+ }
You can’t perform that action at this time.
0 commit comments