@bajetech/digitalbits-wallet-sdk
Version:
A library to make it easier to write wallets that interact with the DigitalBits blockchain
23 lines (19 loc) • 686 B
text/typescript
import DigitalBitsSdk from "xdb-digitalbits-sdk";
import { HandlerSignTransactionParams, KeyTypeHandler } from "../types";
import { KeyType } from "../constants/keys";
export const plaintextKeyHandler: KeyTypeHandler = {
keyType: KeyType.plaintextKey,
signTransaction(params: HandlerSignTransactionParams) {
const { transaction, key } = params;
if (key.privateKey === "") {
throw new Error(
`Non-plaintext key sent to plaintext handler: ${JSON.stringify(
key.publicKey
)}`
);
}
const keyPair = DigitalBitsSdk.Keypair.fromSecret(key.privateKey);
transaction.sign(keyPair);
return Promise.resolve(transaction);
},
};