chaingate
Version:
A complete TypeScript library for connecting to and making transactions on different blockchains
34 lines • 1.39 kB
JavaScript
import { UtxoCurrencyUtils } from '../abstract/UtxoCurrencyUtils/UtxoCurrencyUtils';
import { DogecoinInfo } from '../../CurrencyInfo';
import { PublicKey } from '../../../Wallet/entities/PublicKey';
import * as btc from '@scure/btc-signer';
import { getSignedMessagePublicKey, signMessage, } from '../../CurrencyWallet/abstract/UtxoWallet/MessageSigner';
export class DogecoinUtils extends UtxoCurrencyUtils {
constructor(client, markets) {
super(client, DogecoinInfo, markets, 'dogecoin', {
bech32: null,
pubKeyHash: 0x1e,
scriptHash: 0x16,
wif: 0x9e,
}, '\x19Dogecoin Signed Message:\n');
}
publicKeyToAddress(publicKey) {
const publicKeyRaw = publicKey.raw;
return btc.p2pkh(publicKeyRaw, this.networkParams).address;
}
signMessage(message, privateKey) {
return signMessage(message, privateKey, this.signHeader);
}
async verifySignedMessage(message, signature, address) {
const publicKeyRaw = await getSignedMessagePublicKey(message, signature, this.signHeader);
const publicKey = new PublicKey(publicKeyRaw);
try {
const derivedAddress = this.publicKeyToAddress(publicKey);
return derivedAddress === address;
}
catch {
return false;
}
}
}
//# sourceMappingURL=DogecoinUtils.js.map