-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add testDeriveAddressResult to mock Signed-off-by: Lorenz Herzberger <[email protected]>
- Loading branch information
1 parent
4960ced
commit c4ecb3e
Showing
5 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package types | ||
|
||
// DeriveAddressesResult models the data from the deriveaddresses command. | ||
type DeriveAddressesResult []string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package elementsrpc | ||
|
||
import ( | ||
"github.com/rddl-network/elements-rpc/types" | ||
"github.com/rddl-network/elements-rpc/utils" | ||
) | ||
|
||
func DeriveAddresses(url string, params []string) (addresses types.DeriveAddressesResult, err error) { | ||
result, err := SendRequest(url, types.MethodDeriveAddresses, params) | ||
if err != nil { | ||
return | ||
} | ||
|
||
addresses = utils.ParseResultToArray(result) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package utils | ||
|
||
import "strings" | ||
|
||
func ParseResultToArray(result []byte) (resultArr []string) { | ||
resultStr := string(result) | ||
truncatedStr := resultStr[1 : len(resultStr)-1] // remove [] at beginning and end of Str | ||
sanitizedStr := strings.ReplaceAll(truncatedStr, "\"", "") | ||
|
||
return strings.Split(sanitizedStr, ",") | ||
} |