mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-07-29 21:21:23 +00:00
build
config
core
crypto
api
bitcoin
deps
transactions
arbitrary
signArbitrary.js
signArbitraryWithFee.js
chat
groups
names
polls
reward-share
trade-portal
AirdropTransaction.js
DelegationTransaction.js
DeployAtTransaction.js
MessageTransaction.js
PaymentTransaction.js
PublicizeTransaction.js
TransactionBase.js
TransferPrivsTransaction.js
arbitraryV3.js
processTransaction.js
registerName_dnsthing.js
transactions.js
utils
wallet
PhraseWallet.js
api.js
constants.js
createTransaction.js
createWallet.js
decryptStoredWallet.js
fetch-request.js
kdf.js
registerUsername.js
storeWallet.js
tradeRequest.js
api.js
api_deps.js
config.js
img
lib
locales
plugins
scripts
snap
splash
.editorconfig
.gitattributes
.gitignore
CONTRIBUTING.md
LICENSE
README.md
build-setup.js
build.bat
build.js
build.sh
electron-builder.yml
electron.js
package-lock.json
package.json
run_server.bat
server.js
set-up-snap.sh
watch-inline.js
watch.js
26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
import nacl from '../../deps/nacl-fast'
|
|
import utils from '../../deps/utils'
|
|
import Base58 from '../../deps/Base58'
|
|
|
|
const signArbitraryWithFee = (arbitraryBytesBase58, arbitraryBytesForSigningBase58, keyPair) => {
|
|
if (!arbitraryBytesBase58) {
|
|
throw new Error('ArbitraryBytesBase58 not defined')
|
|
}
|
|
|
|
if (!keyPair) {
|
|
throw new Error('keyPair not defined')
|
|
}
|
|
|
|
const arbitraryBytes = Base58.decode(arbitraryBytesBase58)
|
|
const _arbitraryBytesBuffer = Object.keys(arbitraryBytes).map(function (key) { return arbitraryBytes[key]; })
|
|
const arbitraryBytesBuffer = new Uint8Array(_arbitraryBytesBuffer)
|
|
const arbitraryBytesForSigning = Base58.decode(arbitraryBytesForSigningBase58)
|
|
const _arbitraryBytesForSigningBuffer = Object.keys(arbitraryBytesForSigning).map(function (key) { return arbitraryBytesForSigning[key]; })
|
|
const arbitraryBytesForSigningBuffer = new Uint8Array(_arbitraryBytesForSigningBuffer)
|
|
const signature = nacl.sign.detached(arbitraryBytesForSigningBuffer, keyPair.privateKey)
|
|
|
|
return utils.appendBuffer(arbitraryBytesBuffer, signature)
|
|
}
|
|
|
|
export default signArbitraryWithFee
|