diff --git a/src/assets/images/icon-checkmark.svg b/src/assets/images/icon-checkmark.svg
new file mode 100644
index 00000000..e1a78730
--- /dev/null
+++ b/src/assets/images/icon-checkmark.svg
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/src/assets/images/icon-cross.svg b/src/assets/images/icon-cross.svg
new file mode 100644
index 00000000..62fa417d
--- /dev/null
+++ b/src/assets/images/icon-cross.svg
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/src/assets/images/icon-triangle.svg b/src/assets/images/icon-triangle.svg
new file mode 100644
index 00000000..449b567b
--- /dev/null
+++ b/src/assets/images/icon-triangle.svg
@@ -0,0 +1,5 @@
+
\ No newline at end of file
diff --git a/src/assets/images/icon-wallet.svg b/src/assets/images/icon-wallet.svg
new file mode 100644
index 00000000..e8497c3b
--- /dev/null
+++ b/src/assets/images/icon-wallet.svg
@@ -0,0 +1,4 @@
+
\ No newline at end of file
diff --git a/src/components/composed/RestoreSeedField/RestoreSeedField.css b/src/components/basic/Textarea/Textarea.css
similarity index 65%
rename from src/components/composed/RestoreSeedField/RestoreSeedField.css
rename to src/components/basic/Textarea/Textarea.css
index cb8392b5..662c68ed 100644
--- a/src/components/composed/RestoreSeedField/RestoreSeedField.css
+++ b/src/components/basic/Textarea/Textarea.css
@@ -1,12 +1,13 @@
-.seed-textarea {
+.textarea {
+ width: 100%;
padding: 15px;
resize: none;
}
-.seed-textarea.seed-invalid {
+.textaria-invalid {
border-bottom: 2px solid rgb(var(--color-red));
}
-.seed-textarea.seed-valid {
+.textaria-valid {
border-bottom: 2px solid rgb(var(--color-green));
}
diff --git a/src/components/basic/Textarea/Textarea.js b/src/components/basic/Textarea/Textarea.js
new file mode 100644
index 00000000..650ec081
--- /dev/null
+++ b/src/components/basic/Textarea/Textarea.js
@@ -0,0 +1,49 @@
+import React, { useEffect, useState } from 'react'
+import './Textarea.css'
+
+const Textarea = ({
+ value,
+ onChange,
+ extraClasses,
+ id,
+ size,
+ validity = true,
+ disabled,
+}) => {
+ const [textareaVakue, setTextareaValue] = useState(value ? value : '')
+
+ useEffect(() => {
+ setTextareaValue(value)
+ }, [value])
+
+ const getExtraClasses = () => {
+ if (value && validity) {
+ return 'textaria-valid'
+ } else if (value && !validity) {
+ return 'textaria-invalid'
+ } else {
+ return ''
+ }
+ }
+ const onChangeHandler = ({ target }) => {
+ onChange && onChange({ target })
+ setTextareaValue(target.value)
+ getExtraClasses()
+ }
+
+ return (
+
+ )
+}
+
+export default Textarea
diff --git a/src/components/basic/index.js b/src/components/basic/index.js
index 3bb2326d..232861d6 100644
--- a/src/components/basic/index.js
+++ b/src/components/basic/index.js
@@ -12,6 +12,7 @@ import Logo from './Logo/Logo'
import LogoRound from './LogoRound/LogoRound'
import SkeletonLoader from './SkeletonLoader/SkeletonLoader'
import Tooltip from './Tooltip/Tooltip'
+import Textarea from './Textarea/Textarea'
export {
Arc,
@@ -28,4 +29,5 @@ export {
LogoRound,
SkeletonLoader,
Tooltip,
+ Textarea,
}
diff --git a/src/components/composed/Navigation/Navigation.css b/src/components/composed/Navigation/Navigation.css
index 5ebdd60f..591c4910 100644
--- a/src/components/composed/Navigation/Navigation.css
+++ b/src/components/composed/Navigation/Navigation.css
@@ -4,19 +4,40 @@
padding: 10px 5px;
border-radius: 4px;
cursor: pointer;
+ transition: all 0.2s ease;
}
-.bottom-menu-item:last-child {
+.navigation-item {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ border-radius: 4px;
+ cursor: pointer;
+ transition: all 0.2s ease;
+}
+
+.bottom-menu-item:last-child,
+.navigation-item:last-child {
border-bottom: none;
}
-.bottom-menu-item:hover {
- color: rgb(var(--color-green), var(--nearly-opaque-alpha));
- background-color: rgb(var(--color-extra-light-gray));
+.label-wrapper {
+ display: flex;
+ align-items: center;
+ padding: 10px 5px;
+ border-radius: 4px;
}
-.bottom-menu-item svg {
- width: 20px;
+.bottom-menu-item:hover,
+.navigation-item:hover {
+ color: rgb(var(--color-green), var(--nearly-opaque-alpha));
+ background-color: rgb(var(--color-extra-light-gray));
+}
+
+.bottom-menu-item svg,
+.navigation-item svg {
+ width: 21px;
height: 20px;
margin-right: 10px;
}
@@ -25,5 +46,28 @@
display: flex;
margin-top: 5px;
padding-left: 5px;
- font-size: 0.9rem
+ font-size: 0.9rem;
+}
+
+.navigation-item-open {
+ color: rgb(var(--color-green), var(--nearly-opaque-alpha));
+ background-color: rgb(var(--color-extra-light-gray));
+ padding: 5px;
+ transition: all 0.2s ease;
+}
+
+.navigation-item .navigation-triangle {
+ position: absolute;
+ top: 16px;
+ right: 10px;
+ width: 8px;
+ height: 8px;
+ margin: 0;
+ transform: rotate(180deg);
+ transition: all 0.2s ease;
+}
+
+.navigation-item .navigation-triangle-open {
+ transform: none;
+ top: 21px;
}
diff --git a/src/components/composed/Navigation/Navigation.js b/src/components/composed/Navigation/Navigation.js
index f9f0f0e1..44f8ffce 100644
--- a/src/components/composed/Navigation/Navigation.js
+++ b/src/components/composed/Navigation/Navigation.js
@@ -8,13 +8,20 @@ import { ReactComponent as SettingsImg } from '@Assets/images/settings.svg'
import { ReactComponent as LoginImg } from '@Assets/images/icon-login.svg'
import { ReactComponent as AddWalletImg } from '@Assets/images/icon-add-wallet.svg'
import { ReactComponent as HomeImg } from '@Assets/images/icon-home.svg'
+import { ReactComponent as WalletIcon } from '@Assets/images/icon-wallet.svg'
+import { ReactComponent as TriangleIcon } from '@Assets/images/icon-triangle.svg'
import { AccountContext } from '@Contexts'
+import { AppInfo } from '@Constants'
+
+import NestedNavigation from './NestedNavigation'
import './Navigation.css'
const Navigation = ({ customNavigation }) => {
const [unlocked, setUnlocked] = useState(false)
+ const [navigationItemID, setNavigationItemID] = useState(null)
+ const [nestedItemID, setNestedItemID] = useState(null)
const navigate = useNavigate()
const location = useLocation()
const {
@@ -35,24 +42,24 @@ const Navigation = ({ customNavigation }) => {
setSliderMenuOpen(!sliderMenuOpen)
}
- const goSettings = () => {
- navigate('/settings')
- toggleSliderMenu()
- }
-
- const goDashboard = () => {
- navigate('/dashboard')
- toggleSliderMenu()
- }
-
- const goLogin = () => {
- navigate('/')
- toggleSliderMenu()
+ const onNavigationItemClick = (item) => {
+ if (item.type !== 'menu') {
+ navigate(item.link)
+ toggleSliderMenu()
+ } else {
+ setNavigationItemID(navigationItemID === item.id ? null : item.id)
+ }
+ return
}
- const goCreateAccount = () => {
- navigate('/create-restore')
- toggleSliderMenu()
+ const onNestedItemClick = (item) => {
+ if (item.type !== 'menu') {
+ navigate(item.link)
+ toggleSliderMenu()
+ } else {
+ setNestedItemID(nestedItemID === item.id ? null : item.id)
+ }
+ return
}
const expandHandler = () => {
@@ -76,13 +83,20 @@ const Navigation = ({ customNavigation }) => {
id: 1,
label: 'Dashboard',
icon: ,
- onClick: goDashboard,
+ link: '/dashboard',
},
{
id: 2,
+ label: 'Wallets',
+ icon: ,
+ type: 'menu',
+ content: AppInfo.WALLETS_NAVIGATION,
+ },
+ {
+ id: 3,
label: 'Settings',
icon: ,
- onClick: goSettings,
+ link: '/settings',
},
]
@@ -91,19 +105,22 @@ const Navigation = ({ customNavigation }) => {
id: 1,
label: 'Login',
icon: ,
- onClick: goLogin,
+ link: '/',
+ type: 'link',
},
{
id: 2,
label: 'Create/Restore Wallet',
icon: ,
- onClick: goCreateAccount,
+ link: '/create-restore',
+ type: 'link',
},
{
id: 3,
label: 'Settings',
icon: ,
- onClick: goSettings,
+ link: '/settings',
+ type: 'link',
},
]
@@ -119,11 +136,30 @@ const Navigation = ({ customNavigation }) => {
{navList.map((item) => (
- {item.icon && item.icon}
- {item.label}
+ {
+ onNavigationItemClick(item)
+ }}
+ >
+ {item.icon && item.icon}
+ {item.label}
+
+
+ {item.type === 'menu' && navigationItemID === item.id && (
+
+ )}
+ {item.type === 'menu' && (
+
+ )}
))}
diff --git a/src/components/composed/Navigation/NestedNavigation.css b/src/components/composed/Navigation/NestedNavigation.css
new file mode 100644
index 00000000..fc9e7311
--- /dev/null
+++ b/src/components/composed/Navigation/NestedNavigation.css
@@ -0,0 +1,75 @@
+.nested-menu {
+ margin-top: 10px;
+ background: white;
+ transition: all 0.2s ease;
+}
+
+.nested-menu-item {
+ position: relative;
+ margin-bottom: 1px;
+ border-radius: 4px;
+ cursor: pointer;
+ color: rgb(var(--color-black));
+ background: rgb(230, 245, 230);
+ transition: all 0.2s ease;
+}
+
+.nested-menu-item-open {
+ padding: 5px;
+}
+
+.nested-label-wrapper {
+ display: flex;
+ align-items: center;
+ padding: 10px 15px;
+ transition: all 0.2s ease;
+ border-radius: 4px;
+}
+
+.nested-label-wrapper:hover {
+ color: rgb(var(--color-green), var(--nearly-opaque-alpha));
+ background-color: rgb(210, 235, 210);
+ transition: all 0.2s ease;
+}
+
+.nested-menu-item-open .nested-label-wrapper {
+ color: rgb(var(--color-green), var(--nearly-opaque-alpha));
+ background-color: rgb(210, 235, 210);
+ transition: all 0.2s ease;
+}
+
+.nested-item-menu {
+ margin-top: 5px;
+}
+
+.nested-item-menu-item {
+ display: flex;
+ padding: 10px 15px;
+ margin-bottom: 1px;
+ border-radius: 4px;
+ font-size: 15px;
+ cursor: pointer;
+ background-color: rgb(200, 225, 200);
+ transition: all 0.2s ease;
+}
+
+.nested-item-menu-item:hover {
+ color: rgb(var(--color-white));
+ background-color: rgb(153, 196, 153);
+}
+
+.nested-item-menu .navigation-triangle {
+ position: absolute;
+ top: 16px;
+ right: 10px;
+ width: 8px;
+ height: 8px;
+ margin: 0;
+ transform: rotate(180deg);
+ transition: all 0.2s ease;
+}
+
+.nested-item-menu .navigation-triangle-open {
+ transform: none;
+ top: 21px;
+}
diff --git a/src/components/composed/Navigation/NestedNavigation.js b/src/components/composed/Navigation/NestedNavigation.js
new file mode 100644
index 00000000..e12c80ab
--- /dev/null
+++ b/src/components/composed/Navigation/NestedNavigation.js
@@ -0,0 +1,56 @@
+import React, { useContext } from 'react'
+import { useNavigate } from 'react-router-dom'
+import { ReactComponent as TriangleIcon } from '@Assets/images/icon-triangle.svg'
+
+import { AccountContext } from '@Contexts'
+
+import './NestedNavigation.css'
+
+const NestedNavigation = ({ item, onNestedItemClick, nestedItemID }) => {
+ const { sliderMenuOpen, setSliderMenuOpen } = useContext(AccountContext)
+ const navigate = useNavigate()
+ const toggleSliderMenu = () => {
+ setSliderMenuOpen(!sliderMenuOpen)
+ }
+ return (
+
+ )
+}
+
+export default NestedNavigation
diff --git a/src/components/composed/RestoreSeedField/RestoreSeedField.js b/src/components/composed/RestoreSeedField/RestoreSeedField.js
index b4ff6d82..c325c6eb 100644
--- a/src/components/composed/RestoreSeedField/RestoreSeedField.js
+++ b/src/components/composed/RestoreSeedField/RestoreSeedField.js
@@ -1,7 +1,5 @@
-// import { useState } from 'react'
-import React, { useState } from 'react'
-
-import './RestoreSeedField.css'
+import { useState } from 'react'
+import { Textarea } from '@BasicComponents'
const RestoreSeedField = ({ setFields, accountWordsValid }) => {
const [textareaValue, setTextareaValue] = useState('')
@@ -12,26 +10,18 @@ const RestoreSeedField = ({ setFields, accountWordsValid }) => {
setFields(words)
}
- const getExtraClasses = () => {
- if (textareaValue && accountWordsValid) {
- return 'seed-valid'
- } else if (textareaValue && !accountWordsValid) {
- return 'seed-invalid'
- } else {
- return ''
- }
+ const textariaSize = {
+ cols: 80,
+ rows: 14,
}
return (
-
)
}
diff --git a/src/components/containers/Message/SignMessage/SignMessage.css b/src/components/containers/Message/SignMessage/SignMessage.css
new file mode 100644
index 00000000..273a030a
--- /dev/null
+++ b/src/components/containers/Message/SignMessage/SignMessage.css
@@ -0,0 +1,32 @@
+.message-title,
+.message-description {
+ text-align: center;
+}
+
+.message-submit-button-wrapper {
+ display: flex;
+ justify-content: center;
+}
+
+.message-password {
+ display: flex;
+ justify-content: center;
+}
+
+.message-password input {
+ width: 510px;
+}
+
+.message-submit {
+ width: 510px;
+ padding: 1.7rem 0;
+}
+
+.message-password-field {
+ width: 510px;
+}
+
+.message-button-final {
+ display: flex;
+ gap: 10px;
+}
diff --git a/src/components/containers/Message/SignMessage/SignMessage.js b/src/components/containers/Message/SignMessage/SignMessage.js
new file mode 100644
index 00000000..438c697c
--- /dev/null
+++ b/src/components/containers/Message/SignMessage/SignMessage.js
@@ -0,0 +1,293 @@
+import React, { useState, useContext, useRef, useEffect } from 'react'
+
+import { Button, Textarea, Error } from '@BasicComponents'
+import { TextField, PopUp, Loading } from '@ComposedComponents'
+import { AccountContext, SettingsContext } from '@Contexts'
+import { VerticalGroup } from '@LayoutComponents'
+
+import { ML } from '@Cryptos'
+import { ML as MlHelpers } from '@Helpers'
+import { Account } from '@Entities'
+import { AppInfo } from '@Constants'
+import { ArrayHelper } from '@Helpers'
+
+import './SignMessage.css'
+
+const SignMessage = () => {
+ const submitButtonRef = useRef(null)
+ const [messageValue, setMessageValue] = useState('')
+ const [addressValue, setAddressValue] = useState('')
+ const [signedMessage, setSignedMessage] = useState('')
+ const [openConfirmation, setOpenConfiramtion] = useState(false)
+ const [pass, setPass] = useState('')
+ const [loading, setLoading] = useState(false)
+ const [errorMessage, setErrorMessage] = useState('')
+ const [messageValidity, setMessageValidity] = useState(true)
+ const [addressValidity, setAddressValidity] = useState(true)
+ const [passValidity, setPassValidity] = useState(true)
+ const [passPristinity, setPassPristinity] = useState(true)
+ const [passErrorMessage, setPassErrorMessage] = useState('')
+ const { accountID } = useContext(AccountContext)
+ const { networkType } = useContext(SettingsContext)
+
+ useEffect(() => {
+ if (submitButtonRef.current) {
+ submitButtonRef.current.scrollIntoView({ behavior: 'smooth' })
+ submitButtonRef.current.focus()
+ }
+ }, [signedMessage])
+
+ const findPrivateKeyByAddress = (data, address) => {
+ const { mlReceivingPrivKeys, mlChangePrivKeys } = data
+
+ if (mlReceivingPrivKeys[address]) {
+ return mlReceivingPrivKeys[address]
+ }
+
+ if (mlChangePrivKeys[address]) {
+ return mlChangePrivKeys[address]
+ }
+
+ return false
+ }
+
+ const changePassHandle = (value) => {
+ setPass(value)
+ }
+
+ const onMessageTextfieldChangeHandler = ({ target }) => {
+ setMessageValue(target.value)
+ }
+
+ const onAddressTextfieldChangeHandler = ({ target }) => {
+ setAddressValue(target.value)
+ }
+
+ const isMessageValid = (message) => {
+ return message.length > 0
+ }
+
+ const signMessageHandler = async (id, password) => {
+ const unlockedAccount = await Account.unlockAccount(id, password)
+ if (!pass || !unlockedAccount) {
+ setPassPristinity(false)
+ setPassValidity(false)
+ setLoading(false)
+ setPassErrorMessage('Password must be set.')
+ return
+ }
+
+ const mlPrivKeys = unlockedAccount.mlPrivKeys
+ const privKey =
+ networkType === 'mainnet'
+ ? mlPrivKeys.mlMainnetPrivateKey
+ : mlPrivKeys.mlTestnetPrivateKey
+
+ const walletPrivKeys = ML.getWalletPrivKeysList(
+ privKey,
+ networkType,
+ AppInfo.DEFAULT_ML_WALLET_OFFSET,
+ )
+
+ const addressprivKey = findPrivateKeyByAddress(walletPrivKeys, addressValue)
+
+ if (!addressprivKey) {
+ setPassPristinity(false)
+ setPassValidity(false)
+ setLoading(false)
+ setPassErrorMessage('Address not found in the wallet.')
+ return
+ }
+
+ const messageBytes = ArrayHelper.stringToBytes(messageValue)
+ const signedMessage = ML.signChallenge(addressprivKey, messageBytes)
+ const signedMessageString = ArrayHelper.uint8ArrayToString(signedMessage)
+
+ setSignedMessage(signedMessageString)
+
+ return signedMessage
+ }
+
+ const onConfirmationOpen = () => {
+ if (signedMessage) {
+ setSignedMessage('')
+ setMessageValue('')
+ setAddressValue('')
+ return
+ }
+ setErrorMessage('')
+ const messageIsValid = isMessageValid(messageValue)
+ const isAddressValid = MlHelpers.isMlAddressValid(addressValue, networkType)
+
+ if (!messageIsValid) {
+ setMessageValidity(false)
+ setErrorMessage('Message is required')
+ return
+ }
+
+ if (!addressValue) {
+ setAddressValidity(false)
+ setErrorMessage('Address is required')
+ return
+ }
+
+ if (!isAddressValid) {
+ setAddressValidity(false)
+ setErrorMessage('Invalid address')
+ return
+ }
+ setOpenConfiramtion(true)
+ }
+
+ const onSubmitClick = async (event) => {
+ event.preventDefault()
+ try {
+ setPassValidity(true)
+ setPassErrorMessage('')
+ setLoading(true)
+ const response = await signMessageHandler(accountID, pass)
+ if (response) {
+ setPassValidity(true)
+ setPassErrorMessage('')
+ setLoading(false)
+ setOpenConfiramtion(false)
+ }
+ return response
+ } catch (e) {
+ setLoading(false)
+ console.error(e)
+ setPassPristinity(false)
+ setPassValidity(false)
+ setPass('')
+ setPassErrorMessage('Incorrect password.')
+ }
+ }
+
+ const messageTextariaSize = {
+ cols: 74,
+ rows: 2,
+ }
+
+ const addressTextariaSize = {
+ cols: 74,
+ rows: 1,
+ }
+
+ const signedTextariaSize = {
+ cols: 74,
+ rows: 3,
+ }
+
+ const submitButtonTitle = signedMessage ? 'Sign again' : 'Sign Message'
+
+ return (
+
+ )
+}
+
+export default SignMessage
diff --git a/src/components/containers/Message/VerifyMessage/VerifyMessage.css b/src/components/containers/Message/VerifyMessage/VerifyMessage.css
new file mode 100644
index 00000000..df122dc4
--- /dev/null
+++ b/src/components/containers/Message/VerifyMessage/VerifyMessage.css
@@ -0,0 +1,49 @@
+.message-title,
+.message-description {
+ text-align: center;
+}
+
+.message-submit-button-wrapper {
+ display: flex;
+ justify-content: center;
+}
+
+.message-submit {
+ width: 510px;
+}
+
+.message-button-final {
+ display: flex;
+ gap: 10px;
+}
+
+.icon-verify-success,
+.icon-verify-failed {
+ width: 200px;
+ height: 200px;
+ margin-bottom: 10px;
+}
+
+.icon-verify-success g {
+ fill: rgb(var(--color-light-green));
+}
+
+.icon-verify-failed g {
+ fill: rgb(var(--color-red));
+}
+
+.verify-result {
+ text-align: center;
+}
+
+.message-success {
+ font-weight: 600;
+ text-align: center;
+ color: rgb(var(--color-green));
+}
+
+.message-failed {
+ font-weight: 600;
+ text-align: center;
+ color: rgb(var(--color-red));
+}
diff --git a/src/components/containers/Message/VerifyMessage/VerifyMessage.js b/src/components/containers/Message/VerifyMessage/VerifyMessage.js
new file mode 100644
index 00000000..305fc4d5
--- /dev/null
+++ b/src/components/containers/Message/VerifyMessage/VerifyMessage.js
@@ -0,0 +1,195 @@
+import React, { useState, useContext } from 'react'
+
+import { Button, Textarea, Error } from '@BasicComponents'
+import { VerticalGroup } from '@LayoutComponents'
+import { SettingsContext } from '@Contexts'
+
+import { ML } from '@Cryptos'
+import { ML as MlHelpers } from '@Helpers'
+import { ArrayHelper } from '@Helpers'
+
+import './VerifyMessage.css'
+
+const VerifyMessage = () => {
+ const { networkType } = useContext(SettingsContext)
+ const [errorMessage, setErrorMessage] = useState('')
+ const [originalMessageValue, setOriginalMessageValue] = useState('')
+ const [signedMessageValue, setSignedMessageValue] = useState('')
+ const [addressValue, setAddressValue] = useState('')
+ const [isVerified, setIsVerified] = useState(undefined)
+
+ const originalMessageFieldChangeHandler = ({ target }) => {
+ setOriginalMessageValue(target.value)
+ }
+ const signedMessageFieldChangeHandler = ({ target }) => {
+ setSignedMessageValue(target.value)
+ }
+
+ const addressFieldChangeHandler = ({ target }) => {
+ setAddressValue(target.value)
+ }
+
+ const verifyMessageHandler = (address, signedMessage, originalMessage) => {
+ const signedMessageUint8Array =
+ ArrayHelper.stringToUint8Array(signedMessage)
+ const messageBytes = ArrayHelper.stringToBytes(originalMessage)
+
+ const verifyMessage = ML.verifyChallenge(
+ address,
+ networkType,
+ signedMessageUint8Array,
+ messageBytes,
+ )
+
+ return verifyMessage
+ }
+
+ const onSubmitClick = (e) => {
+ e.preventDefault()
+ if (isVerified !== undefined) {
+ setIsVerified(undefined)
+ setErrorMessage('')
+ setOriginalMessageValue('')
+ setAddressValue('')
+ setSignedMessageValue('')
+ return
+ }
+ setErrorMessage('')
+ const isAddressValid = MlHelpers.isMlAddressValid(addressValue, networkType)
+
+ if (!originalMessageValue) {
+ setErrorMessage('Please enter the original message.')
+ return
+ }
+
+ if (!addressValue) {
+ setErrorMessage('Please enter the address.')
+ return
+ }
+
+ if (!isAddressValid) {
+ setErrorMessage('Please enter correct address.')
+ return
+ }
+
+ if (!signedMessageValue) {
+ setErrorMessage('Please enter correct signed message.')
+ return
+ }
+
+ try {
+ const isVerified = verifyMessageHandler(
+ addressValue,
+ signedMessageValue,
+ originalMessageValue,
+ )
+ setIsVerified(isVerified)
+ } catch (e) {
+ console.error(e)
+ setIsVerified(false)
+ return
+ }
+ }
+
+ const textariaSize = {
+ cols: 74,
+ rows: 2,
+ }
+
+ const textariaAddressSize = {
+ cols: 74,
+ rows: 1,
+ }
+
+ const submitButtonTitle = isVerified !== undefined ? 'Try Again' : 'Verify'
+ return (
+
+ )
+}
+
+export default VerifyMessage
diff --git a/src/components/containers/index.js b/src/components/containers/index.js
index 27335a05..5f50cd13 100644
--- a/src/components/containers/index.js
+++ b/src/components/containers/index.js
@@ -26,6 +26,9 @@ import SettingsTestnet from './Settings/SettingsTestnet/SettingsTestnet'
import SettingsAPI from './Settings/SettingsAPI/SettingsAPI'
import SettingsBackup from './Settings/SettingsBackup/SettingsBackup'
+import SignMessage from './Message/SignMessage/SignMessage'
+import VerifyMessage from './Message/VerifyMessage/VerifyMessage'
+
/* istanbul ignore next */
const Wallet = {
ShowAddress,
@@ -62,6 +65,11 @@ const RestoreAccount = {
RestoreAccountJson,
}
+const Message = {
+ SignMessage,
+ VerifyMessage,
+}
+
export {
CreateAccount,
RestoreAccount,
@@ -71,4 +79,5 @@ export {
SendTransaction,
Dashboard,
Settings,
+ Message,
}
diff --git a/src/index.js b/src/index.js
index ce830a06..b1eb6ce8 100644
--- a/src/index.js
+++ b/src/index.js
@@ -27,6 +27,7 @@ import {
DelegationStakePage,
DelegationWithdrawPage,
LockedBalancePage,
+ MessagePage,
} from '@Pages'
import {
@@ -239,6 +240,10 @@ const App = () => {
path="/wallet/:coinType/locked-balance"
element={}
/>
+ }
+ />
{
+ const [activeTab, setActiveTab] = useState('sign')
+
+ return (
+
+
+
+
+
+
+ {activeTab === 'sign' ? (
+
+ ) : (
+
+ )}
+
+
+ )
+}
+
+export default MessagePage
diff --git a/src/pages/index.js b/src/pages/index.js
index c17b8dd7..8ee71ebd 100644
--- a/src/pages/index.js
+++ b/src/pages/index.js
@@ -14,6 +14,7 @@ import CreateDelegationPage from './CreateDelegation/CreateDelegation'
import DelegationStakePage from './DelegationStake/DelegationStake'
import DelegationWithdrawPage from './DelegationWithdraw/DelegationWithdraw'
import LockedBalancePage from './LockedBalance/LockedBalance'
+import MessagePage from './MessagePage/MessagePage'
export {
CreateAccountPage,
@@ -31,5 +32,6 @@ export {
CreateDelegationPage,
DelegationStakePage,
DelegationWithdrawPage,
- LockedBalancePage
+ LockedBalancePage,
+ MessagePage,
}
diff --git a/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers.d.ts b/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers.d.ts
index 58151f91..1b711511 100644
--- a/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers.d.ts
+++ b/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers.d.ts
@@ -96,6 +96,34 @@ export function verify_signature_for_spending(
signature: Uint8Array,
message: Uint8Array,
): boolean
+/**
+ * Given a message and a private key, create and sign a challenge with the given private key
+ * This kind of signature is to be used when signing challenges.
+ * @param {Uint8Array} private_key
+ * @param {Uint8Array} message
+ * @returns {Uint8Array}
+ */
+export function sign_challenge(
+ private_key: Uint8Array,
+ message: Uint8Array,
+): Uint8Array
+/**
+ * Given a signed challenge, an address and a message. Verify that
+ * the signature is produced by signing the message with the private key
+ * that derived the given public key.
+ * Note that this function is used for verifying messages related challenges.
+ * @param {string} address
+ * @param {Network} network
+ * @param {Uint8Array} signed_challenge
+ * @param {Uint8Array} message
+ * @returns {boolean}
+ */
+export function verify_challenge(
+ address: string,
+ network: Network,
+ signed_challenge: Uint8Array,
+ message: Uint8Array,
+): boolean
/**
* Given a destination address, an amount and a network type (mainnet, testnet, etc), this function
* creates an output of type Transfer, and returns it as bytes.
@@ -407,6 +435,42 @@ export function encode_output_issue_nft(
* @returns {Uint8Array}
*/
export function encode_output_data_deposit(data: Uint8Array): Uint8Array
+/**
+ * Given the parameters needed to create hash timelock contract, and a network type (mainnet, testnet, etc),
+ * this function creates an output.
+ * @param {Amount} amount
+ * @param {string | undefined} token_id
+ * @param {string} secret_hash
+ * @param {string} spend_address
+ * @param {string} refund_address
+ * @param {Uint8Array} refund_timelock
+ * @param {Network} network
+ * @returns {Uint8Array}
+ */
+export function encode_output_htlc(
+ amount: Amount,
+ token_id: string | undefined,
+ secret_hash: string,
+ spend_address: string,
+ refund_address: string,
+ refund_timelock: Uint8Array,
+ network: Network,
+): Uint8Array
+/**
+ * Given a signed transaction and input outpoint that spends an htlc utxo, extract a secret that is
+ * encoded in the corresponding input signature
+ * @param {Uint8Array} signed_tx_bytes
+ * @param {boolean} strict_byte_size
+ * @param {Uint8Array} htlc_outpoint_source_id
+ * @param {number} htlc_output_index
+ * @returns {Uint8Array}
+ */
+export function extract_htlc_secret(
+ signed_tx_bytes: Uint8Array,
+ strict_byte_size: boolean,
+ htlc_outpoint_source_id: Uint8Array,
+ htlc_output_index: number,
+): Uint8Array
/**
* Given an output source id as bytes, and an output index, together representing a utxo,
* this function returns the input that puts them together, as bytes.
@@ -440,6 +504,7 @@ export function encode_input_for_withdraw_from_delegation(
* for Account inputs that spend from a delegation it is the owning address of that delegation,
* and in the case of AccountCommand inputs which change a token it is the token's authority destination)
* and the outputs, estimate the transaction size.
+ * ScriptHash and ClassicMultisig destinations are not supported.
* @param {Uint8Array} inputs
* @param {(string)[]} input_utxos_destinations
* @param {Uint8Array} outputs
@@ -492,7 +557,71 @@ export function encode_witness(
network: Network,
): Uint8Array
/**
- * Given an unsigned transaction, and signatures, this function returns a SignedTransaction object as bytes.
+ * Given a private key, inputs and an input number to sign, and the destination that owns that output (through the utxo),
+ * and a network type (mainnet, testnet, etc), and an htlc secret this function returns a witness to be used in a signed transaction, as bytes.
+ * @param {SignatureHashType} sighashtype
+ * @param {Uint8Array} private_key_bytes
+ * @param {string} input_owner_destination
+ * @param {Uint8Array} transaction_bytes
+ * @param {Uint8Array} inputs
+ * @param {number} input_num
+ * @param {Uint8Array} secret
+ * @param {Network} network
+ * @returns {Uint8Array}
+ */
+export function encode_witness_htlc_secret(
+ sighashtype: SignatureHashType,
+ private_key_bytes: Uint8Array,
+ input_owner_destination: string,
+ transaction_bytes: Uint8Array,
+ inputs: Uint8Array,
+ input_num: number,
+ secret: Uint8Array,
+ network: Network,
+): Uint8Array
+/**
+ * Given an arbitrary number of public keys as bytes, number of minimum required signatures, and a network type, this function returns
+ * the multisig challenge, as bytes.
+ * @param {Uint8Array} public_keys_bytes
+ * @param {number} min_required_signatures
+ * @param {Network} network
+ * @returns {Uint8Array}
+ */
+export function encode_multisig_challenge(
+ public_keys_bytes: Uint8Array,
+ min_required_signatures: number,
+ network: Network,
+): Uint8Array
+/**
+ * Given a private key, inputs and an input number to sign, and multisig challenge,
+ * and a network type (mainnet, testnet, etc), this function returns a witness to be used in a signed transaction, as bytes.
+ *
+ * `key_index` parameter is an index of a public key in the challenge, against which is the signature produces from private key is to be verified.
+ * `input_witness` parameter can be either empty or a result of previous calls to this function.
+ * @param {SignatureHashType} sighashtype
+ * @param {Uint8Array} private_key_bytes
+ * @param {number} key_index
+ * @param {Uint8Array} input_witness
+ * @param {Uint8Array} multisig_challenge
+ * @param {Uint8Array} transaction_bytes
+ * @param {Uint8Array} utxos
+ * @param {number} input_num
+ * @param {Network} network
+ * @returns {Uint8Array}
+ */
+export function encode_witness_htlc_multisig(
+ sighashtype: SignatureHashType,
+ private_key_bytes: Uint8Array,
+ key_index: number,
+ input_witness: Uint8Array,
+ multisig_challenge: Uint8Array,
+ transaction_bytes: Uint8Array,
+ utxos: Uint8Array,
+ input_num: number,
+ network: Network,
+): Uint8Array
+/**
+ * Given an unsigned transaction and signatures, this function returns a SignedTransaction object as bytes.
* @param {Uint8Array} transaction_bytes
* @param {Uint8Array} signatures
* @returns {Uint8Array}
@@ -533,11 +662,11 @@ export function effective_pool_balance(
pool_balance: Amount,
): Amount
/**
- * Indicates whether a token can be frozen
+ * A utxo can either come from a transaction or a block reward. This enum signifies that.
*/
-export enum FreezableToken {
- No = 0,
- Yes = 1,
+export enum SourceId {
+ Transaction = 0,
+ BlockReward = 1,
}
/**
* The token supply of a specific token, set on issuance
@@ -556,15 +685,6 @@ export enum TotalSupply {
*/
Fixed = 2,
}
-/**
- * The part of the transaction that will be committed in the signature. Similar to bitcoin's sighash.
- */
-export enum SignatureHashType {
- ALL = 0,
- NONE = 1,
- SINGLE = 2,
- ANYONECANPAY = 3,
-}
/**
* The network, for which an operation to be done. Mainnet, testnet, etc.
*/
@@ -575,11 +695,20 @@ export enum Network {
Signet = 3,
}
/**
- * A utxo can either come from a transaction or a block reward. This enum signifies that.
+ * The part of the transaction that will be committed in the signature. Similar to bitcoin's sighash.
*/
-export enum SourceId {
- Transaction = 0,
- BlockReward = 1,
+export enum SignatureHashType {
+ ALL = 0,
+ NONE = 1,
+ SINGLE = 2,
+ ANYONECANPAY = 3,
+}
+/**
+ * Indicates whether a token can be frozen
+ */
+export enum FreezableToken {
+ No = 0,
+ Yes = 1,
}
/**
* Amount type abstraction. The amount type is stored in a string
@@ -609,7 +738,7 @@ export type InitInput =
export interface InitOutput {
readonly memory: WebAssembly.Memory
- readonly __wbg_amount_free: (a: number) => void
+ readonly __wbg_amount_free: (a: number, b: number) => void
readonly amount_from_atoms: (a: number, b: number) => number
readonly amount_atoms: (a: number, b: number) => void
readonly encode_outpoint_source_id: (
@@ -664,6 +793,23 @@ export interface InitOutput {
f: number,
g: number,
) => void
+ readonly sign_challenge: (
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ ) => void
+ readonly verify_challenge: (
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ f: number,
+ g: number,
+ h: number,
+ ) => void
readonly encode_output_transfer: (
a: number,
b: number,
@@ -798,6 +944,30 @@ export interface InitOutput {
w: number,
) => void
readonly encode_output_data_deposit: (a: number, b: number, c: number) => void
+ readonly encode_output_htlc: (
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ f: number,
+ g: number,
+ h: number,
+ i: number,
+ j: number,
+ k: number,
+ l: number,
+ m: number,
+ ) => void
+ readonly extract_htlc_secret: (
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ f: number,
+ g: number,
+ ) => void
readonly encode_input_for_utxo: (
a: number,
b: number,
@@ -845,6 +1015,46 @@ export interface InitOutput {
k: number,
l: number,
) => void
+ readonly encode_witness_htlc_secret: (
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ f: number,
+ g: number,
+ h: number,
+ i: number,
+ j: number,
+ k: number,
+ l: number,
+ m: number,
+ n: number,
+ ) => void
+ readonly encode_multisig_challenge: (
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ ) => void
+ readonly encode_witness_htlc_multisig: (
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ f: number,
+ g: number,
+ h: number,
+ i: number,
+ j: number,
+ k: number,
+ l: number,
+ m: number,
+ n: number,
+ o: number,
+ ) => void
readonly encode_signed_transaction: (
a: number,
b: number,
@@ -891,20 +1101,25 @@ export type SyncInitInput = BufferSource | WebAssembly.Module
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
- * @param {SyncInitInput} module
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
*
* @returns {InitOutput}
*/
-export function initSync(module: SyncInitInput): InitOutput
+export function initSync(
+ module: { module: SyncInitInput } | SyncInitInput,
+): InitOutput
/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
- * @param {InitInput | Promise} module_or_path
+ * @param {{ module_or_path: InitInput | Promise }} module_or_path - Passing `InitInput` directly is deprecated.
*
* @returns {Promise}
*/
export default function __wbg_init(
- module_or_path?: InitInput | Promise,
+ module_or_path?:
+ | { module_or_path: InitInput | Promise }
+ | InitInput
+ | Promise,
): Promise
diff --git a/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers.js b/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers.js
index f9c97c7d..e991bbdc 100644
--- a/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers.js
+++ b/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers.js
@@ -19,18 +19,23 @@ if (typeof TextDecoder !== 'undefined') {
cachedTextDecoder.decode()
}
-let cachedUint8Memory0 = null
+let cachedUint8ArrayMemory0 = null
-function getUint8Memory0() {
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer)
+function getUint8ArrayMemory0() {
+ if (
+ cachedUint8ArrayMemory0 === null ||
+ cachedUint8ArrayMemory0.byteLength === 0
+ ) {
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer)
}
- return cachedUint8Memory0
+ return cachedUint8ArrayMemory0
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len))
+ return cachedTextDecoder.decode(
+ getUint8ArrayMemory0().subarray(ptr, ptr + len),
+ )
}
const heap = new Array(128).fill(undefined)
@@ -93,7 +98,7 @@ function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg)
const ptr = malloc(buf.length, 1) >>> 0
- getUint8Memory0()
+ getUint8ArrayMemory0()
.subarray(ptr, ptr + buf.length)
.set(buf)
WASM_VECTOR_LEN = buf.length
@@ -103,7 +108,7 @@ function passStringToWasm0(arg, malloc, realloc) {
let len = arg.length
let ptr = malloc(len, 1) >>> 0
- const mem = getUint8Memory0()
+ const mem = getUint8ArrayMemory0()
let offset = 0
@@ -118,7 +123,7 @@ function passStringToWasm0(arg, malloc, realloc) {
arg = arg.slice(offset)
}
ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len)
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len)
const ret = encodeString(arg, view)
offset += ret.written
@@ -133,25 +138,30 @@ function isLikeNone(x) {
return x === undefined || x === null
}
-let cachedInt32Memory0 = null
+let cachedDataViewMemory0 = null
-function getInt32Memory0() {
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer)
+function getDataViewMemory0() {
+ if (
+ cachedDataViewMemory0 === null ||
+ cachedDataViewMemory0.buffer.detached === true ||
+ (cachedDataViewMemory0.buffer.detached === undefined &&
+ cachedDataViewMemory0.buffer !== wasm.memory.buffer)
+ ) {
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer)
}
- return cachedInt32Memory0
+ return cachedDataViewMemory0
}
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1, 1) >>> 0
- getUint8Memory0().set(arg, ptr / 1)
+ getUint8ArrayMemory0().set(arg, ptr / 1)
WASM_VECTOR_LEN = arg.length
return ptr
}
function getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len)
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len)
}
/**
* A utxo can either come from a transaction or a block reward.
@@ -168,8 +178,8 @@ export function encode_outpoint_source_id(id, source) {
const ptr0 = passArray8ToWasm0(id, wasm.__wbindgen_malloc)
const len0 = WASM_VECTOR_LEN
wasm.encode_outpoint_source_id(retptr, ptr0, len0, source)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
var v2 = getArrayU8FromWasm0(r0, r1).slice()
wasm.__wbindgen_free(r0, r1 * 1, 1)
return v2
@@ -186,8 +196,8 @@ export function make_private_key() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
wasm.make_private_key(retptr)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
var v1 = getArrayU8FromWasm0(r0, r1).slice()
wasm.__wbindgen_free(r0, r1 * 1, 1)
return v1
@@ -213,10 +223,10 @@ export function make_default_account_privkey(mnemonic, network) {
)
const len0 = WASM_VECTOR_LEN
wasm.make_default_account_privkey(retptr, ptr0, len0, network)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -241,10 +251,10 @@ export function make_receiving_address(private_key_bytes, key_index) {
const ptr0 = passArray8ToWasm0(private_key_bytes, wasm.__wbindgen_malloc)
const len0 = WASM_VECTOR_LEN
wasm.make_receiving_address(retptr, ptr0, len0, key_index)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -269,10 +279,10 @@ export function make_change_address(private_key_bytes, key_index) {
const ptr0 = passArray8ToWasm0(private_key_bytes, wasm.__wbindgen_malloc)
const len0 = WASM_VECTOR_LEN
wasm.make_change_address(retptr, ptr0, len0, key_index)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -299,10 +309,10 @@ export function pubkey_to_pubkeyhash_address(public_key_bytes, network) {
const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc)
const len0 = WASM_VECTOR_LEN
wasm.pubkey_to_pubkeyhash_address(retptr, ptr0, len0, network)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
var ptr2 = r0
var len2 = r1
if (r3) {
@@ -330,10 +340,10 @@ export function public_key_from_private_key(private_key) {
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc)
const len0 = WASM_VECTOR_LEN
wasm.public_key_from_private_key(retptr, ptr0, len0)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -361,10 +371,10 @@ export function sign_message_for_spending(private_key, message) {
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc)
const len1 = WASM_VECTOR_LEN
wasm.sign_message_for_spending(retptr, ptr0, len0, ptr1, len1)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -405,9 +415,76 @@ export function verify_signature_for_spending(public_key, signature, message) {
ptr2,
len2,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ if (r2) {
+ throw takeObject(r1)
+ }
+ return r0 !== 0
+ } finally {
+ wasm.__wbindgen_add_to_stack_pointer(16)
+ }
+}
+
+/**
+ * Given a message and a private key, create and sign a challenge with the given private key
+ * This kind of signature is to be used when signing challenges.
+ * @param {Uint8Array} private_key
+ * @param {Uint8Array} message
+ * @returns {Uint8Array}
+ */
+export function sign_challenge(private_key, message) {
+ try {
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
+ const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc)
+ const len0 = WASM_VECTOR_LEN
+ const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc)
+ const len1 = WASM_VECTOR_LEN
+ wasm.sign_challenge(retptr, ptr0, len0, ptr1, len1)
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
+ if (r3) {
+ throw takeObject(r2)
+ }
+ var v3 = getArrayU8FromWasm0(r0, r1).slice()
+ wasm.__wbindgen_free(r0, r1 * 1, 1)
+ return v3
+ } finally {
+ wasm.__wbindgen_add_to_stack_pointer(16)
+ }
+}
+
+/**
+ * Given a signed challenge, an address and a message. Verify that
+ * the signature is produced by signing the message with the private key
+ * that derived the given public key.
+ * Note that this function is used for verifying messages related challenges.
+ * @param {string} address
+ * @param {Network} network
+ * @param {Uint8Array} signed_challenge
+ * @param {Uint8Array} message
+ * @returns {boolean}
+ */
+export function verify_challenge(address, network, signed_challenge, message) {
+ try {
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
+ const ptr0 = passStringToWasm0(
+ address,
+ wasm.__wbindgen_malloc,
+ wasm.__wbindgen_realloc,
+ )
+ const len0 = WASM_VECTOR_LEN
+ const ptr1 = passArray8ToWasm0(signed_challenge, wasm.__wbindgen_malloc)
+ const len1 = WASM_VECTOR_LEN
+ const ptr2 = passArray8ToWasm0(message, wasm.__wbindgen_malloc)
+ const len2 = WASM_VECTOR_LEN
+ wasm.verify_challenge(retptr, ptr0, len0, network, ptr1, len1, ptr2, len2)
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
if (r2) {
throw takeObject(r1)
}
@@ -443,10 +520,10 @@ export function encode_output_transfer(amount, address, network) {
)
const len1 = WASM_VECTOR_LEN
wasm.encode_output_transfer(retptr, ptr0, ptr1, len1, network)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -498,10 +575,10 @@ export function encode_output_token_transfer(
len2,
network,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -544,8 +621,8 @@ export function encode_lock_for_block_count(block_count) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
wasm.encode_lock_for_block_count(retptr, block_count)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
var v1 = getArrayU8FromWasm0(r0, r1).slice()
wasm.__wbindgen_free(r0, r1 * 1, 1)
return v1
@@ -565,8 +642,8 @@ export function encode_lock_for_seconds(total_seconds) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
wasm.encode_lock_for_seconds(retptr, total_seconds)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
var v1 = getArrayU8FromWasm0(r0, r1).slice()
wasm.__wbindgen_free(r0, r1 * 1, 1)
return v1
@@ -586,8 +663,8 @@ export function encode_lock_until_time(timestamp_since_epoch_in_seconds) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
wasm.encode_lock_until_time(retptr, timestamp_since_epoch_in_seconds)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
var v1 = getArrayU8FromWasm0(r0, r1).slice()
wasm.__wbindgen_free(r0, r1 * 1, 1)
return v1
@@ -606,8 +683,8 @@ export function encode_lock_until_height(block_height) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
wasm.encode_lock_until_height(retptr, block_height)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
var v1 = getArrayU8FromWasm0(r0, r1).slice()
wasm.__wbindgen_free(r0, r1 * 1, 1)
return v1
@@ -653,10 +730,10 @@ export function encode_output_lock_then_transfer(
len2,
network,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -715,10 +792,10 @@ export function encode_output_token_lock_then_transfer(
len3,
network,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -741,10 +818,10 @@ export function encode_output_coin_burn(amount) {
_assertClass(amount, Amount)
var ptr0 = amount.__destroy_into_raw()
wasm.encode_output_coin_burn(retptr, ptr0)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -776,10 +853,10 @@ export function encode_output_token_burn(amount, token_id, network) {
)
const len1 = WASM_VECTOR_LEN
wasm.encode_output_token_burn(retptr, ptr0, ptr1, len1, network)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -827,10 +904,10 @@ export function encode_output_create_delegation(
len1,
network,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -862,10 +939,10 @@ export function encode_output_delegate_staking(amount, delegation_id, network) {
)
const len1 = WASM_VECTOR_LEN
wasm.encode_output_delegate_staking(retptr, ptr0, ptr1, len1, network)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -935,10 +1012,10 @@ export function encode_stake_pool_data(
ptr4,
network,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -979,10 +1056,10 @@ export function encode_output_create_stake_pool(pool_id, pool_data, network) {
len1,
network,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -1115,10 +1192,10 @@ export function encode_output_issue_fungible_token(
_current_block_height,
network,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -1240,10 +1317,10 @@ export function encode_output_issue_nft(
_current_block_height,
network,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -1266,10 +1343,10 @@ export function encode_output_data_deposit(data) {
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc)
const len0 = WASM_VECTOR_LEN
wasm.encode_output_data_deposit(retptr, ptr0, len0)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -1281,6 +1358,137 @@ export function encode_output_data_deposit(data) {
}
}
+/**
+ * Given the parameters needed to create hash timelock contract, and a network type (mainnet, testnet, etc),
+ * this function creates an output.
+ * @param {Amount} amount
+ * @param {string | undefined} token_id
+ * @param {string} secret_hash
+ * @param {string} spend_address
+ * @param {string} refund_address
+ * @param {Uint8Array} refund_timelock
+ * @param {Network} network
+ * @returns {Uint8Array}
+ */
+export function encode_output_htlc(
+ amount,
+ token_id,
+ secret_hash,
+ spend_address,
+ refund_address,
+ refund_timelock,
+ network,
+) {
+ try {
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
+ _assertClass(amount, Amount)
+ var ptr0 = amount.__destroy_into_raw()
+ var ptr1 = isLikeNone(token_id)
+ ? 0
+ : passStringToWasm0(
+ token_id,
+ wasm.__wbindgen_malloc,
+ wasm.__wbindgen_realloc,
+ )
+ var len1 = WASM_VECTOR_LEN
+ const ptr2 = passStringToWasm0(
+ secret_hash,
+ wasm.__wbindgen_malloc,
+ wasm.__wbindgen_realloc,
+ )
+ const len2 = WASM_VECTOR_LEN
+ const ptr3 = passStringToWasm0(
+ spend_address,
+ wasm.__wbindgen_malloc,
+ wasm.__wbindgen_realloc,
+ )
+ const len3 = WASM_VECTOR_LEN
+ const ptr4 = passStringToWasm0(
+ refund_address,
+ wasm.__wbindgen_malloc,
+ wasm.__wbindgen_realloc,
+ )
+ const len4 = WASM_VECTOR_LEN
+ const ptr5 = passArray8ToWasm0(refund_timelock, wasm.__wbindgen_malloc)
+ const len5 = WASM_VECTOR_LEN
+ wasm.encode_output_htlc(
+ retptr,
+ ptr0,
+ ptr1,
+ len1,
+ ptr2,
+ len2,
+ ptr3,
+ len3,
+ ptr4,
+ len4,
+ ptr5,
+ len5,
+ network,
+ )
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
+ if (r3) {
+ throw takeObject(r2)
+ }
+ var v7 = getArrayU8FromWasm0(r0, r1).slice()
+ wasm.__wbindgen_free(r0, r1 * 1, 1)
+ return v7
+ } finally {
+ wasm.__wbindgen_add_to_stack_pointer(16)
+ }
+}
+
+/**
+ * Given a signed transaction and input outpoint that spends an htlc utxo, extract a secret that is
+ * encoded in the corresponding input signature
+ * @param {Uint8Array} signed_tx_bytes
+ * @param {boolean} strict_byte_size
+ * @param {Uint8Array} htlc_outpoint_source_id
+ * @param {number} htlc_output_index
+ * @returns {Uint8Array}
+ */
+export function extract_htlc_secret(
+ signed_tx_bytes,
+ strict_byte_size,
+ htlc_outpoint_source_id,
+ htlc_output_index,
+) {
+ try {
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
+ const ptr0 = passArray8ToWasm0(signed_tx_bytes, wasm.__wbindgen_malloc)
+ const len0 = WASM_VECTOR_LEN
+ const ptr1 = passArray8ToWasm0(
+ htlc_outpoint_source_id,
+ wasm.__wbindgen_malloc,
+ )
+ const len1 = WASM_VECTOR_LEN
+ wasm.extract_htlc_secret(
+ retptr,
+ ptr0,
+ len0,
+ strict_byte_size,
+ ptr1,
+ len1,
+ htlc_output_index,
+ )
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
+ if (r3) {
+ throw takeObject(r2)
+ }
+ var v3 = getArrayU8FromWasm0(r0, r1).slice()
+ wasm.__wbindgen_free(r0, r1 * 1, 1)
+ return v3
+ } finally {
+ wasm.__wbindgen_add_to_stack_pointer(16)
+ }
+}
+
/**
* Given an output source id as bytes, and an output index, together representing a utxo,
* this function returns the input that puts them together, as bytes.
@@ -1294,10 +1502,10 @@ export function encode_input_for_utxo(outpoint_source_id, output_index) {
const ptr0 = passArray8ToWasm0(outpoint_source_id, wasm.__wbindgen_malloc)
const len0 = WASM_VECTOR_LEN
wasm.encode_input_for_utxo(retptr, ptr0, len0, output_index)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -1343,10 +1551,10 @@ export function encode_input_for_withdraw_from_delegation(
nonce,
network,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -1358,20 +1566,11 @@ export function encode_input_for_withdraw_from_delegation(
}
}
-let cachedUint32Memory0 = null
-
-function getUint32Memory0() {
- if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
- cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer)
- }
- return cachedUint32Memory0
-}
-
function passArrayJsValueToWasm0(array, malloc) {
const ptr = malloc(array.length * 4, 4) >>> 0
- const mem = getUint32Memory0()
+ const mem = getDataViewMemory0()
for (let i = 0; i < array.length; i++) {
- mem[ptr / 4 + i] = addHeapObject(array[i])
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true)
}
WASM_VECTOR_LEN = array.length
return ptr
@@ -1382,6 +1581,7 @@ function passArrayJsValueToWasm0(array, malloc) {
* for Account inputs that spend from a delegation it is the owning address of that delegation,
* and in the case of AccountCommand inputs which change a token it is the token's authority destination)
* and the outputs, estimate the transaction size.
+ * ScriptHash and ClassicMultisig destinations are not supported.
* @param {Uint8Array} inputs
* @param {(string)[]} input_utxos_destinations
* @param {Uint8Array} outputs
@@ -1415,9 +1615,9 @@ export function estimate_transaction_size(
len2,
network,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
if (r2) {
throw takeObject(r1)
}
@@ -1443,10 +1643,10 @@ export function encode_transaction(inputs, outputs, flags) {
const ptr1 = passArray8ToWasm0(outputs, wasm.__wbindgen_malloc)
const len1 = WASM_VECTOR_LEN
wasm.encode_transaction(retptr, ptr0, len0, ptr1, len1, flags)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -1466,8 +1666,8 @@ export function encode_witness_no_signature() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
wasm.encode_witness_no_signature(retptr)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
var v1 = getArrayU8FromWasm0(r0, r1).slice()
wasm.__wbindgen_free(r0, r1 * 1, 1)
return v1
@@ -1525,10 +1725,10 @@ export function encode_witness(
input_num,
network,
)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -1541,7 +1741,188 @@ export function encode_witness(
}
/**
- * Given an unsigned transaction, and signatures, this function returns a SignedTransaction object as bytes.
+ * Given a private key, inputs and an input number to sign, and the destination that owns that output (through the utxo),
+ * and a network type (mainnet, testnet, etc), and an htlc secret this function returns a witness to be used in a signed transaction, as bytes.
+ * @param {SignatureHashType} sighashtype
+ * @param {Uint8Array} private_key_bytes
+ * @param {string} input_owner_destination
+ * @param {Uint8Array} transaction_bytes
+ * @param {Uint8Array} inputs
+ * @param {number} input_num
+ * @param {Uint8Array} secret
+ * @param {Network} network
+ * @returns {Uint8Array}
+ */
+export function encode_witness_htlc_secret(
+ sighashtype,
+ private_key_bytes,
+ input_owner_destination,
+ transaction_bytes,
+ inputs,
+ input_num,
+ secret,
+ network,
+) {
+ try {
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
+ const ptr0 = passArray8ToWasm0(private_key_bytes, wasm.__wbindgen_malloc)
+ const len0 = WASM_VECTOR_LEN
+ const ptr1 = passStringToWasm0(
+ input_owner_destination,
+ wasm.__wbindgen_malloc,
+ wasm.__wbindgen_realloc,
+ )
+ const len1 = WASM_VECTOR_LEN
+ const ptr2 = passArray8ToWasm0(transaction_bytes, wasm.__wbindgen_malloc)
+ const len2 = WASM_VECTOR_LEN
+ const ptr3 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc)
+ const len3 = WASM_VECTOR_LEN
+ const ptr4 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc)
+ const len4 = WASM_VECTOR_LEN
+ wasm.encode_witness_htlc_secret(
+ retptr,
+ sighashtype,
+ ptr0,
+ len0,
+ ptr1,
+ len1,
+ ptr2,
+ len2,
+ ptr3,
+ len3,
+ input_num,
+ ptr4,
+ len4,
+ network,
+ )
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
+ if (r3) {
+ throw takeObject(r2)
+ }
+ var v6 = getArrayU8FromWasm0(r0, r1).slice()
+ wasm.__wbindgen_free(r0, r1 * 1, 1)
+ return v6
+ } finally {
+ wasm.__wbindgen_add_to_stack_pointer(16)
+ }
+}
+
+/**
+ * Given an arbitrary number of public keys as bytes, number of minimum required signatures, and a network type, this function returns
+ * the multisig challenge, as bytes.
+ * @param {Uint8Array} public_keys_bytes
+ * @param {number} min_required_signatures
+ * @param {Network} network
+ * @returns {Uint8Array}
+ */
+export function encode_multisig_challenge(
+ public_keys_bytes,
+ min_required_signatures,
+ network,
+) {
+ try {
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
+ const ptr0 = passArray8ToWasm0(public_keys_bytes, wasm.__wbindgen_malloc)
+ const len0 = WASM_VECTOR_LEN
+ wasm.encode_multisig_challenge(
+ retptr,
+ ptr0,
+ len0,
+ min_required_signatures,
+ network,
+ )
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
+ if (r3) {
+ throw takeObject(r2)
+ }
+ var v2 = getArrayU8FromWasm0(r0, r1).slice()
+ wasm.__wbindgen_free(r0, r1 * 1, 1)
+ return v2
+ } finally {
+ wasm.__wbindgen_add_to_stack_pointer(16)
+ }
+}
+
+/**
+ * Given a private key, inputs and an input number to sign, and multisig challenge,
+ * and a network type (mainnet, testnet, etc), this function returns a witness to be used in a signed transaction, as bytes.
+ *
+ * `key_index` parameter is an index of a public key in the challenge, against which is the signature produces from private key is to be verified.
+ * `input_witness` parameter can be either empty or a result of previous calls to this function.
+ * @param {SignatureHashType} sighashtype
+ * @param {Uint8Array} private_key_bytes
+ * @param {number} key_index
+ * @param {Uint8Array} input_witness
+ * @param {Uint8Array} multisig_challenge
+ * @param {Uint8Array} transaction_bytes
+ * @param {Uint8Array} utxos
+ * @param {number} input_num
+ * @param {Network} network
+ * @returns {Uint8Array}
+ */
+export function encode_witness_htlc_multisig(
+ sighashtype,
+ private_key_bytes,
+ key_index,
+ input_witness,
+ multisig_challenge,
+ transaction_bytes,
+ utxos,
+ input_num,
+ network,
+) {
+ try {
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
+ const ptr0 = passArray8ToWasm0(private_key_bytes, wasm.__wbindgen_malloc)
+ const len0 = WASM_VECTOR_LEN
+ const ptr1 = passArray8ToWasm0(input_witness, wasm.__wbindgen_malloc)
+ const len1 = WASM_VECTOR_LEN
+ const ptr2 = passArray8ToWasm0(multisig_challenge, wasm.__wbindgen_malloc)
+ const len2 = WASM_VECTOR_LEN
+ const ptr3 = passArray8ToWasm0(transaction_bytes, wasm.__wbindgen_malloc)
+ const len3 = WASM_VECTOR_LEN
+ const ptr4 = passArray8ToWasm0(utxos, wasm.__wbindgen_malloc)
+ const len4 = WASM_VECTOR_LEN
+ wasm.encode_witness_htlc_multisig(
+ retptr,
+ sighashtype,
+ ptr0,
+ len0,
+ key_index,
+ ptr1,
+ len1,
+ ptr2,
+ len2,
+ ptr3,
+ len3,
+ ptr4,
+ len4,
+ input_num,
+ network,
+ )
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
+ if (r3) {
+ throw takeObject(r2)
+ }
+ var v6 = getArrayU8FromWasm0(r0, r1).slice()
+ wasm.__wbindgen_free(r0, r1 * 1, 1)
+ return v6
+ } finally {
+ wasm.__wbindgen_add_to_stack_pointer(16)
+ }
+}
+
+/**
+ * Given an unsigned transaction and signatures, this function returns a SignedTransaction object as bytes.
* @param {Uint8Array} transaction_bytes
* @param {Uint8Array} signatures
* @returns {Uint8Array}
@@ -1554,10 +1935,10 @@ export function encode_signed_transaction(transaction_bytes, signatures) {
const ptr1 = passArray8ToWasm0(signatures, wasm.__wbindgen_malloc)
const len1 = WASM_VECTOR_LEN
wasm.encode_signed_transaction(retptr, ptr0, len0, ptr1, len1)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
if (r3) {
throw takeObject(r2)
}
@@ -1591,10 +1972,10 @@ export function get_transaction_id(transaction_bytes, strict_byte_size) {
const ptr0 = passArray8ToWasm0(transaction_bytes, wasm.__wbindgen_malloc)
const len0 = WASM_VECTOR_LEN
wasm.get_transaction_id(retptr, ptr0, len0, strict_byte_size)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
- var r3 = getInt32Memory0()[retptr / 4 + 3]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true)
var ptr2 = r0
var len2 = r1
if (r3) {
@@ -1627,9 +2008,9 @@ export function effective_pool_balance(network, pledge_amount, pool_balance) {
_assertClass(pool_balance, Amount)
var ptr1 = pool_balance.__destroy_into_raw()
wasm.effective_pool_balance(retptr, network, ptr0, ptr1)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
- var r2 = getInt32Memory0()[retptr / 4 + 2]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true)
if (r2) {
throw takeObject(r1)
}
@@ -1647,13 +2028,13 @@ function handleError(f, args) {
}
}
/**
- * Indicates whether a token can be frozen
+ * A utxo can either come from a transaction or a block reward. This enum signifies that.
*/
-export const FreezableToken = Object.freeze({
- No: 0,
- 0: 'No',
- Yes: 1,
- 1: 'Yes',
+export const SourceId = Object.freeze({
+ Transaction: 0,
+ 0: 'Transaction',
+ BlockReward: 1,
+ 1: 'BlockReward',
})
/**
* The token supply of a specific token, set on issuance
@@ -1675,19 +2056,6 @@ export const TotalSupply = Object.freeze({
Fixed: 2,
2: 'Fixed',
})
-/**
- * The part of the transaction that will be committed in the signature. Similar to bitcoin's sighash.
- */
-export const SignatureHashType = Object.freeze({
- ALL: 0,
- 0: 'ALL',
- NONE: 1,
- 1: 'NONE',
- SINGLE: 2,
- 2: 'SINGLE',
- ANYONECANPAY: 3,
- 3: 'ANYONECANPAY',
-})
/**
* The network, for which an operation to be done. Mainnet, testnet, etc.
*/
@@ -1702,19 +2070,32 @@ export const Network = Object.freeze({
3: 'Signet',
})
/**
- * A utxo can either come from a transaction or a block reward. This enum signifies that.
+ * The part of the transaction that will be committed in the signature. Similar to bitcoin's sighash.
*/
-export const SourceId = Object.freeze({
- Transaction: 0,
- 0: 'Transaction',
- BlockReward: 1,
- 1: 'BlockReward',
+export const SignatureHashType = Object.freeze({
+ ALL: 0,
+ 0: 'ALL',
+ NONE: 1,
+ 1: 'NONE',
+ SINGLE: 2,
+ 2: 'SINGLE',
+ ANYONECANPAY: 3,
+ 3: 'ANYONECANPAY',
+})
+/**
+ * Indicates whether a token can be frozen
+ */
+export const FreezableToken = Object.freeze({
+ No: 0,
+ 0: 'No',
+ Yes: 1,
+ 1: 'Yes',
})
const AmountFinalization =
typeof FinalizationRegistry === 'undefined'
? { register: () => {}, unregister: () => {} }
- : new FinalizationRegistry((ptr) => wasm.__wbg_amount_free(ptr >>> 0))
+ : new FinalizationRegistry((ptr) => wasm.__wbg_amount_free(ptr >>> 0, 1))
/**
* Amount type abstraction. The amount type is stored in a string
* since JavaScript number type cannot fit 128-bit integers.
@@ -1739,7 +2120,7 @@ export class Amount {
free() {
const ptr = this.__destroy_into_raw()
- wasm.__wbg_amount_free(ptr)
+ wasm.__wbg_amount_free(ptr, 0)
}
/**
* @param {string} atoms
@@ -1765,8 +2146,8 @@ export class Amount {
const ptr = this.__destroy_into_raw()
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16)
wasm.amount_atoms(retptr, ptr)
- var r0 = getInt32Memory0()[retptr / 4 + 0]
- var r1 = getInt32Memory0()[retptr / 4 + 1]
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true)
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true)
deferred1_0 = r0
deferred1_1 = r1
return getStringFromWasm0(r0, r1)
@@ -1817,7 +2198,7 @@ function __wbg_get_imports() {
imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
takeObject(arg0)
}
- imports.wbg.__wbg_crypto_566d7465cdbb6b7a = function (arg0) {
+ imports.wbg.__wbg_crypto_1d1f22824a6a080c = function (arg0) {
const ret = getObject(arg0).crypto
return addHeapObject(ret)
}
@@ -1826,15 +2207,15 @@ function __wbg_get_imports() {
const ret = typeof val === 'object' && val !== null
return ret
}
- imports.wbg.__wbg_process_dc09a8c7d59982f6 = function (arg0) {
+ imports.wbg.__wbg_process_4a72847cc503995b = function (arg0) {
const ret = getObject(arg0).process
return addHeapObject(ret)
}
- imports.wbg.__wbg_versions_d98c6400c6ca2bd8 = function (arg0) {
+ imports.wbg.__wbg_versions_f686565e586dd935 = function (arg0) {
const ret = getObject(arg0).versions
return addHeapObject(ret)
}
- imports.wbg.__wbg_node_caaf83d002149bd5 = function (arg0) {
+ imports.wbg.__wbg_node_104a2ff8d6ea03a2 = function (arg0) {
const ret = getObject(arg0).node
return addHeapObject(ret)
}
@@ -1842,11 +2223,7 @@ function __wbg_get_imports() {
const ret = typeof getObject(arg0) === 'string'
return ret
}
- imports.wbg.__wbg_msCrypto_0b84745e9245cdf6 = function (arg0) {
- const ret = getObject(arg0).msCrypto
- return addHeapObject(ret)
- }
- imports.wbg.__wbg_require_94a9da52636aacbf = function () {
+ imports.wbg.__wbg_require_cca90b1a94a0255b = function () {
return handleError(function () {
const ret = module.require
return addHeapObject(ret)
@@ -1856,21 +2233,25 @@ function __wbg_get_imports() {
const ret = typeof getObject(arg0) === 'function'
return ret
}
- imports.wbg.__wbg_randomFillSync_290977693942bf03 = function () {
+ imports.wbg.__wbg_msCrypto_eb05e62b530a1508 = function (arg0) {
+ const ret = getObject(arg0).msCrypto
+ return addHeapObject(ret)
+ }
+ imports.wbg.__wbg_randomFillSync_5c9c955aa56b6049 = function () {
return handleError(function (arg0, arg1) {
getObject(arg0).randomFillSync(takeObject(arg1))
}, arguments)
}
- imports.wbg.__wbg_getRandomValues_260cc23a41afad9a = function () {
+ imports.wbg.__wbg_getRandomValues_3aa56aa6edec874c = function () {
return handleError(function (arg0, arg1) {
getObject(arg0).getRandomValues(getObject(arg1))
}, arguments)
}
- imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function (arg0, arg1) {
+ imports.wbg.__wbg_newnoargs_76313bd6ff35d0f2 = function (arg0, arg1) {
const ret = new Function(getStringFromWasm0(arg0, arg1))
return addHeapObject(ret)
}
- imports.wbg.__wbg_call_27c0f87801dedf93 = function () {
+ imports.wbg.__wbg_call_1084a111329e68ce = function () {
return handleError(function (arg0, arg1) {
const ret = getObject(arg0).call(getObject(arg1))
return addHeapObject(ret)
@@ -1883,32 +2264,32 @@ function __wbg_get_imports() {
? 0
: passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc)
var len1 = WASM_VECTOR_LEN
- getInt32Memory0()[arg0 / 4 + 1] = len1
- getInt32Memory0()[arg0 / 4 + 0] = ptr1
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true)
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true)
}
imports.wbg.__wbindgen_object_clone_ref = function (arg0) {
const ret = getObject(arg0)
return addHeapObject(ret)
}
- imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function () {
+ imports.wbg.__wbg_self_3093d5d1f7bcb682 = function () {
return handleError(function () {
const ret = self.self
return addHeapObject(ret)
}, arguments)
}
- imports.wbg.__wbg_window_c6fb939a7f436783 = function () {
+ imports.wbg.__wbg_window_3bcfc4d31bc012f8 = function () {
return handleError(function () {
const ret = window.window
return addHeapObject(ret)
}, arguments)
}
- imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function () {
+ imports.wbg.__wbg_globalThis_86b222e13bdf32ed = function () {
return handleError(function () {
const ret = globalThis.globalThis
return addHeapObject(ret)
}, arguments)
}
- imports.wbg.__wbg_global_207b558942527489 = function () {
+ imports.wbg.__wbg_global_e5a3fe56f8be9485 = function () {
return handleError(function () {
const ret = global.global
return addHeapObject(ret)
@@ -1918,17 +2299,17 @@ function __wbg_get_imports() {
const ret = getObject(arg0) === undefined
return ret
}
- imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function () {
+ imports.wbg.__wbg_call_89af060b4e1523f2 = function () {
return handleError(function (arg0, arg1, arg2) {
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2))
return addHeapObject(ret)
}, arguments)
}
- imports.wbg.__wbg_buffer_12d079cc21e14bdb = function (arg0) {
+ imports.wbg.__wbg_buffer_b7b08af79b0b0974 = function (arg0) {
const ret = getObject(arg0).buffer
return addHeapObject(ret)
}
- imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function (
+ imports.wbg.__wbg_newwithbyteoffsetandlength_8a2cb9ca96b27ec9 = function (
arg0,
arg1,
arg2,
@@ -1936,18 +2317,18 @@ function __wbg_get_imports() {
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0)
return addHeapObject(ret)
}
- imports.wbg.__wbg_new_63b92bc8671ed464 = function (arg0) {
+ imports.wbg.__wbg_new_ea1883e1e5e86686 = function (arg0) {
const ret = new Uint8Array(getObject(arg0))
return addHeapObject(ret)
}
- imports.wbg.__wbg_set_a47bac70306a19a7 = function (arg0, arg1, arg2) {
+ imports.wbg.__wbg_set_d1e79e2388520f18 = function (arg0, arg1, arg2) {
getObject(arg0).set(getObject(arg1), arg2 >>> 0)
}
- imports.wbg.__wbg_newwithlength_e9b4878cebadb3d3 = function (arg0) {
+ imports.wbg.__wbg_newwithlength_ec548f448387c968 = function (arg0) {
const ret = new Uint8Array(arg0 >>> 0)
return addHeapObject(ret)
}
- imports.wbg.__wbg_subarray_a1f73cd4b5b42fe1 = function (arg0, arg1, arg2) {
+ imports.wbg.__wbg_subarray_7c2e3576afe181d1 = function (arg0, arg1, arg2) {
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0)
return addHeapObject(ret)
}
@@ -1962,14 +2343,13 @@ function __wbg_get_imports() {
return imports
}
-function __wbg_init_memory(imports, maybe_memory) {}
+function __wbg_init_memory(imports, memory) {}
function __wbg_finalize_init(instance, module) {
wasm = instance.exports
__wbg_init.__wbindgen_wasm_module = module
- cachedInt32Memory0 = null
- cachedUint32Memory0 = null
- cachedUint8Memory0 = null
+ cachedDataViewMemory0 = null
+ cachedUint8ArrayMemory0 = null
return wasm
}
@@ -1977,6 +2357,16 @@ function __wbg_finalize_init(instance, module) {
function initSync(module) {
if (wasm !== undefined) return wasm
+ if (
+ typeof module !== 'undefined' &&
+ Object.getPrototypeOf(module) === Object.prototype
+ )
+ ({ module } = module)
+ else
+ console.warn(
+ 'using deprecated parameters for `initSync()`; pass a single object instead',
+ )
+
const imports = __wbg_get_imports()
__wbg_init_memory(imports)
@@ -1990,25 +2380,35 @@ function initSync(module) {
return __wbg_finalize_init(instance, module)
}
-async function __wbg_init(input) {
+async function __wbg_init(module_or_path) {
if (wasm !== undefined) return wasm
- if (typeof input === 'undefined') {
- input = new URL('wasm_wrappers_bg.wasm', import.meta.url)
+ if (
+ typeof module_or_path !== 'undefined' &&
+ Object.getPrototypeOf(module_or_path) === Object.prototype
+ )
+ ({ module_or_path } = module_or_path)
+ else
+ console.warn(
+ 'using deprecated parameters for the initialization function; pass a single object instead',
+ )
+
+ if (typeof module_or_path === 'undefined') {
+ module_or_path = new URL('wasm_wrappers_bg.wasm', import.meta.url)
}
const imports = __wbg_get_imports()
if (
- typeof input === 'string' ||
- (typeof Request === 'function' && input instanceof Request) ||
- (typeof URL === 'function' && input instanceof URL)
+ typeof module_or_path === 'string' ||
+ (typeof Request === 'function' && module_or_path instanceof Request) ||
+ (typeof URL === 'function' && module_or_path instanceof URL)
) {
- input = fetch(input)
+ module_or_path = fetch(module_or_path)
}
__wbg_init_memory(imports)
- const { instance, module } = await __wbg_load(await input, imports)
+ const { instance, module } = await __wbg_load(await module_or_path, imports)
return __wbg_finalize_init(instance, module)
}
diff --git a/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers_bg.wasm b/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers_bg.wasm
index 0cfe3039..fa176790 100644
Binary files a/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers_bg.wasm and b/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers_bg.wasm differ
diff --git a/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers_bg.wasm.d.ts b/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers_bg.wasm.d.ts
index b63b332c..6c300013 100644
--- a/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers_bg.wasm.d.ts
+++ b/src/services/Crypto/Mintlayer/@mintlayerlib-js/wasm_wrappers_bg.wasm.d.ts
@@ -1,7 +1,7 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory
-export function __wbg_amount_free(a: number): void
+export function __wbg_amount_free(a: number, b: number): void
export function amount_from_atoms(a: number, b: number): number
export function amount_atoms(a: number, b: number): void
export function encode_outpoint_source_id(
@@ -56,6 +56,23 @@ export function verify_signature_for_spending(
f: number,
g: number,
): void
+export function sign_challenge(
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+): void
+export function verify_challenge(
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ f: number,
+ g: number,
+ h: number,
+): void
export function encode_output_transfer(
a: number,
b: number,
@@ -194,6 +211,30 @@ export function encode_output_data_deposit(
b: number,
c: number,
): void
+export function encode_output_htlc(
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ f: number,
+ g: number,
+ h: number,
+ i: number,
+ j: number,
+ k: number,
+ l: number,
+ m: number,
+): void
+export function extract_htlc_secret(
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ f: number,
+ g: number,
+): void
export function encode_input_for_utxo(
a: number,
b: number,
@@ -241,6 +282,46 @@ export function encode_witness(
k: number,
l: number,
): void
+export function encode_witness_htlc_secret(
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ f: number,
+ g: number,
+ h: number,
+ i: number,
+ j: number,
+ k: number,
+ l: number,
+ m: number,
+ n: number,
+): void
+export function encode_multisig_challenge(
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+): void
+export function encode_witness_htlc_multisig(
+ a: number,
+ b: number,
+ c: number,
+ d: number,
+ e: number,
+ f: number,
+ g: number,
+ h: number,
+ i: number,
+ j: number,
+ k: number,
+ l: number,
+ m: number,
+ n: number,
+ o: number,
+): void
export function encode_signed_transaction(
a: number,
b: number,
diff --git a/src/services/Crypto/Mintlayer/Mintlayer.js b/src/services/Crypto/Mintlayer/Mintlayer.js
index 1695c3ed..0f2b3d32 100644
--- a/src/services/Crypto/Mintlayer/Mintlayer.js
+++ b/src/services/Crypto/Mintlayer/Mintlayer.js
@@ -22,6 +22,10 @@ import init, {
SourceId,
Amount,
encode_output_token_transfer,
+ sign_message_for_spending,
+ verify_signature_for_spending,
+ sign_challenge,
+ verify_challenge,
} from './@mintlayerlib-js/wasm_wrappers.js'
import { Mintlayer } from '@APIs'
@@ -291,3 +295,25 @@ export const getAccountOutpointInput = (
networkIndex,
)
}
+
+export const signMessageForSpending = (privateKey, message) => {
+ return sign_message_for_spending(privateKey, message)
+}
+
+export const verifySignatureForSpending = (publicKey, signature, message) => {
+ return verify_signature_for_spending(publicKey, signature, message)
+}
+
+export const signChallenge = (privateKey, message) => {
+ return sign_challenge(privateKey, message)
+}
+
+export const verifyChallenge = (
+ address,
+ networkType,
+ signedChallenge,
+ message,
+) => {
+ const networkIndex = NETWORKS[networkType]
+ return verify_challenge(address, networkIndex, signedChallenge, message)
+}
diff --git a/src/utils/Constants/AppInfo/AppInfo.js b/src/utils/Constants/AppInfo/AppInfo.js
index 85f26f0d..e0e39369 100644
--- a/src/utils/Constants/AppInfo/AppInfo.js
+++ b/src/utils/Constants/AppInfo/AppInfo.js
@@ -18,6 +18,7 @@ const APPROPRIATE_MARGIN_RATIO_PER_THOUSAND = 80
const UNCONFIRMED_TRANSACTION_NAME = 'ml_unconfirmed_transaction'
const APP_LOCAL_STORAGE_CUSTOM_SERVERS = 'customAPIServers'
const MAX_UPLOAD_FILE_SIZE = 2 * 1024 // 2 kb
+const SIGNED_MESSAGE_STRING_SEPARATOR = '.'
const NETWORK_TYPES = {
MAINNET: 'mainnet',
@@ -47,6 +48,55 @@ const walletTypes = [
},
]
+const WALLETS_NAVIGATION = [
+ {
+ id: '1',
+ label: 'Bitcoin',
+ value: 'bitcoin',
+ type: 'menu',
+ actions: [
+ {
+ id: '1.1',
+ name: 'Open Wallet',
+ link: '/wallet/Bitcoin',
+ },
+ {
+ id: '1.2',
+ name: 'Send Transaction',
+ link: '/wallet/Bitcoin/send-transaction',
+ },
+ ],
+ },
+ {
+ id: '2',
+ label: 'Mintlayer',
+ value: 'mintlayer',
+ type: 'menu',
+ actions: [
+ {
+ id: '2.1',
+ name: 'Open Wallet',
+ link: '/wallet/Mintlayer',
+ },
+ {
+ id: '2.2',
+ name: 'Send Transaction',
+ link: '/wallet/Mintlayer/send-transaction',
+ },
+ {
+ id: '2.3',
+ name: 'Staking',
+ link: '/wallet/Mintlayer/staking',
+ },
+ {
+ id: '2.4',
+ name: 'Sign/Verify Message',
+ link: '/wallet/Mintlayer/sign-message',
+ },
+ ],
+ },
+]
+
const MAX_ML_FEE = 500000000000
const REFRESH_INTERVAL = 1000 * 60 // one per minute
@@ -70,4 +120,6 @@ export {
APP_LOCAL_STORAGE_CUSTOM_SERVERS,
REFRESH_INTERVAL,
MAX_UPLOAD_FILE_SIZE,
+ WALLETS_NAVIGATION,
+ SIGNED_MESSAGE_STRING_SEPARATOR,
}
diff --git a/src/utils/Helpers/Array/Array.js b/src/utils/Helpers/Array/Array.js
index cd07ecaa..b1bede54 100644
--- a/src/utils/Helpers/Array/Array.js
+++ b/src/utils/Helpers/Array/Array.js
@@ -22,4 +22,33 @@ const removeDublicates = (arr) => {
})
}
-export { getNRandomElementsFromArray, removeDublicates }
+const uint8ArrayToString = (uint8Array) => {
+ let binaryString = ''
+ for (let i = 0; i < uint8Array.length; i++) {
+ binaryString += String.fromCharCode(uint8Array[i])
+ }
+ return btoa(binaryString)
+}
+
+const stringToUint8Array = (string) => {
+ const binaryString = atob(string)
+ const len = binaryString.length
+ const uint8Array = new Uint8Array(len)
+ for (let i = 0; i < len; i++) {
+ uint8Array[i] = binaryString.charCodeAt(i)
+ }
+ return uint8Array
+}
+
+const stringToBytes = (string) => {
+ const encoder = new TextEncoder()
+ return encoder.encode(string)
+}
+
+export {
+ getNRandomElementsFromArray,
+ removeDublicates,
+ uint8ArrayToString,
+ stringToUint8Array,
+ stringToBytes,
+}