Skip to content

Commit

Permalink
Merge branch 'refs/heads/openbit-dev' into koni/dev/test-api-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
bluezdot committed Jul 16, 2024
2 parents 87c7357 + 790b592 commit e55094d
Show file tree
Hide file tree
Showing 123 changed files with 3,697 additions and 772 deletions.
5 changes: 4 additions & 1 deletion .123trigger
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,7 @@
1.1.41
1.1.42
1.1.43
1.1.44
1.1.44
1.1.45
1.1.46
1.1.47
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,61 @@
# CHANGELOG

## 1.1.47
Build date: Jun 29, 2024.

Features & Updates:
- Support dApp Providers (Bitcoin Provider) (#85)
- Add "Beta" for OpenBit version (#199)
- Update chainlist (#225) :
- Add support for more tokens on BounceBit (#251)
- Add support for Ethereum Sepolia network (#249)


## 1.1.46
Build date: Jun 27, 2024.

Features & Updates:
- Add support Ordinal with video format (#202)
- Add support for ORDINALS•RUNES token (#212)


## 1.1.45
Build date: Jun 26, 2024.

Features & Updates:
- Update chain-list (#183)
- Update multi-chain asset for some tokens
- Update price & logo
- Add support BounceBit testnet network
- Add support for Bitlayer Lucky Helmet NFT (#243)
- Add support for LayerEdge Testnet (#241)
- Update chainlist (#206)
- Add support for MERL token (#245)
- Add support for BEVM OP Testnet (#244)
- Handle show inscriptions by batch (#182)
- Handle show address on Receive feature (#209)
- Update currency symbol (#214)
- Update subwallet-react-ui
- Update content for some message (#159)
- Update loading for fee selection on send Fund screen (175)
- Update confirmation, history screen (#44)

Bug Fixes:
- Error can re-import brc20 token even though the token is already in the wallet (#194)
- Fix bug Can't import Rune with decimals = 0 (#170)
- Update API for calculate fee rate (189)
- Fix bug do not show Block time
- Fix API return type (#187)


## 1.1.44
Build date: Jun 21, 2024.

Features & Updates:
- Support Firefox

## 1.1.43
Build date: Jun 12, 2024.

Features & Updates:
- First version with basic Bitcoin & EVM Features
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
2444 AnhMTV Release version 1.1.44
2467 AnhMTV Release version 1.1.47
2171 Nam Phạm [Issue 2717] change XCM ref map
2001 S2kael [Issue-193] Add re-scan BTC transaction have no block_time
757 lw-cdm [UI] Update fee selector logic
798 lw-cdm Fix issue related to send fund
465 Jaco 0.42.5 (#969)
185 quangdo
156 nguyentiendung [Issue-44] hotfix to resetForm case change contractAddress
144 bluezdot Revert "[Issue-189] optimize speed get bitcoin balance"
168 nguyentiendung [Issue-202] Add support video for ordinals
167 bluezdot [Issue-225] Update chainlist
104 khainh predefine metadata for Polkadot & Kusama chains
99 lw-cdm
88 dominhquang [Issue-2649] Add send crash log feature
87 Hieu Dao Update README.md
85 leewong Update color
83 Hieu Dao Update README.md
82 Thibaut Sardan Add account filtering feature (#832)
63 Roman fix ui issues
53 Dominhquangdev update Bridge code
53 Thiendekaco fix: transaction response for dapp
48 bluedot [Runes] Merge openbit-dev--migrate-code
30 Thiendekaco [Issue 3109] [build] [mv3] Extension - Auto build for firefox mv3
29 Automation Bot [CI Skip] Auto increase webapp build number
26 S2kael
10 louisdangw3 Check logic of transaction-service and request-serivce
Expand Down
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
## OpenBit Extension
Our OpenBit is forked from polkadot-js/extension. We aim to adding more features while being able to rebase the polkadot-js origin at any time.

One-stop-shop multichain wallet for the Bitcoin ecosystem

![OpenBit Beta launch annoucement](https://github.com/openbitdev/OpenBit-Wallet/assets/2582652/6bfcfc27-f471-481c-a58e-ca31174f3fe6)

As the first Bitcoin multichain wallet and super dApp, OpenBit provides a one-stop-shop that allows users to connect to and explore diverse use cases on Bitcoin, Bitcoin L2s and Multichain on one single interface. With the mission of onboarding multichain users to the Bitcoin ecosystem and driving the Bitcoin economy forward, OpenBit serves as a crucial gateway through which users can navigate the multi-VM Bitcoin ecosystem with utmost ease and absolute security.

**Attention**: OpenBit is in beta version, so use it at your own risk. We recommend only using testnets to try out features at the moment.

OpenBit Bitcoin wallet key features

1. Send and receive BTC with custom fees on a sleek UI
2. View your L1 asset balance including inscriptions, BRC-20 and Runes tokens
3. View your Ordinals collectibles
4. Navigate the multichain ecosystem with Bitcoin, Bitcoin L2s and EVM networks
5. Import and manage custom EVM networks
6. Connect to multiple dApps with ease

And many more!

Asset and network support

1. Assets supported include inscriptions, BRC-20, Runes and Ordinals collectibles
2. Networks supported include Bitcoin, Ethereum, Merlin Chain, Bitlayer, BOB,…

## Main Concept
![Main Concept](https://github.com/openbitdev/OpenBit-Wallet/wiki/images/ExtensionConcept.png)

The extension is compiled from folder `packages/extension-koni`
- **Background environment**: The Background environment is compiled from `packages/extension-koni/src/background.ts`.
- The Background is use to handle message from Extensions pages and Chrome tabs via Chrome API Message Passing.
Expand Down Expand Up @@ -66,7 +90,7 @@ Store is used to persist data into local storage. Stores is defined in folder `p
```

## Add a message handle
Subwallet extension use message passing concept via browser API to interact between Background - Extensions - Chrome Tabs.
Openbit extension use message passing concept via browser API to interact between Background - Extensions - Chrome Tabs.
- Extension or Chrome Tabs send a message with id and type to Background
- Background handle message by id and type and response data.
- There are 2 message type:
Expand Down Expand Up @@ -114,7 +138,7 @@ Cronjob is define in folder `packages/extension-koni-base/src/cron`.
- messaging.ts: Send to background and handle return message.

### Add new redux store
- Subwallet extension use [redux-tookit](https://redux-toolkit.js.org/) to generate store.
- Openbit extension use [redux-tookit](https://redux-toolkit.js.org/) to generate store.
- Define redux store reducers and state into separate file by method `createSlice` of redux toolkit.
- Map reducer into root store in file index.ts

Expand All @@ -125,7 +149,7 @@ Read "Add a message handle"
Extension auto validate code with eslint. Please setup eslint in editor and run `yarn lint` before commit code.

## Write test
Subwallet run test with [jest](https://jestjs.io/). Create new file with name `filename.spec.ts` to write test.
Openbit run test with [jest](https://jestjs.io/). Create new file with name `filename.spec.ts` to write test.

## Commit and Build
- Please run `yarn lint` and `yarn test`
Expand Down
25 changes: 14 additions & 11 deletions local-libs/keyring/cjs/pair/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createPair = createPair;
var _bip322Js = require("bip322-js");
var bitcoin = _interopRequireWildcard(require("bitcoinjs-lib"));
var _bitcoinjsMessage = require("bitcoinjs-message");
var _ecpair = require("ecpair");
var _ethSimpleKeyring = _interopRequireDefault(require("eth-simple-keyring"));
var ecc = _interopRequireWildcard(require("tiny-secp256k1"));
Expand Down Expand Up @@ -108,13 +108,13 @@ function createPair(_ref, _ref2) {
const encodeAddress = () => {
const raw = _utils.TYPE_ADDRESS[type](publicKey);
const bitNetwork = ['bitcoin-44', 'bitcoin-84', 'bitcoin-86'].includes(type) ? bitcoin.networks.bitcoin : ['bittest-44', 'bittest-84', 'bittest-86'].includes(type) ? bitcoin.networks.testnet : bitcoin.networks.regtest;
let dataKey;

/**
* With bitcoin accounts, some attached account have no public key (only address).
* In this case, public key is the hash of result after decoded address.
* Add `noPublicKey` in metadata for this case.
*/
let dataKey;
if (meta.noPublicKey) {
dataKey = 'hash';
} else {
Expand Down Expand Up @@ -316,34 +316,37 @@ function createPair(_ref, _ref2) {
type
}, derived, meta, null);
},
signMessage: (message, compressed, options) => {
signMessage: message => {
if (isLocked(secretKey)) {
throw new Error('Cannot encrypt with a locked key pair');
}
const _message = typeof message === 'string' ? message : Buffer.from(message);
const _message = typeof message === 'string' ? message : (0, _util.u8aToString)(message);
const address = encodeAddress();
const _pair = ECPair.fromPrivateKey(Buffer.from(secretKey));
const wif = _pair.toWIF();

// Sign the message
const signature = (0, _bitcoinjsMessage.sign)(_message, Buffer.from(secretKey), compressed, options);
return signature.toString('base64');
const signature = _bip322Js.Signer.sign(wif, address, _message);
return typeof signature === 'string' ? signature : signature.toString('base64');
},
signTransaction: (transaction, indexes) => {
signTransaction: (psbt, indexes, sighashTypes, tapLeafHashToSign) => {
if (isLocked(secretKey)) {
throw new Error('Cannot encrypt with a locked key pair');
}
if (!transaction) {
if (!psbt) {
throw new Error('Not found sign method');
}
const pair = ECPair.fromPrivateKey(Buffer.from(secretKey));
const isTaproot = ['bitcoin-86', 'bittest-86'].includes(type);
for (const index of indexes) {
if (isTaproot) {
const tweakedSigner = pair.tweak(bitcoin.crypto.taggedHash('TapTweak', toXOnly(pair.publicKey)));
transaction.signTaprootInput(index, tweakedSigner);
psbt.signTaprootInput(index, tweakedSigner, tapLeafHashToSign, sighashTypes);
} else {
transaction.signInput(index, pair);
psbt.signInput(index, pair, sighashTypes);
}
}
return transaction;
return psbt;
},
get output() {
return output || Buffer.from([]);
Expand Down
10 changes: 9 additions & 1 deletion local-libs/keyring/cjs/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BitcoinAddressType = void 0;
exports.SubstrateKeypairTypes = exports.EthereumKeypairTypes = exports.BitcoinKeypairTypes = exports.BitcoinAddressType = void 0;
// Copyright 2017-2022 @polkadot/keyring authors & contributors
// SPDX-License-Identifier: Apache-2.0

/**
*
*
* */

const SubstrateKeypairTypes = ['sr25519', 'ed25519', 'ecdsa'];
exports.SubstrateKeypairTypes = SubstrateKeypairTypes;
const EthereumKeypairTypes = ['ethereum'];
exports.EthereumKeypairTypes = EthereumKeypairTypes;
const BitcoinKeypairTypes = ['bitcoin-44', 'bitcoin-84', 'bitcoin-86', 'bittest-44', 'bittest-84', 'bittest-86'];
exports.BitcoinKeypairTypes = BitcoinKeypairTypes;
let BitcoinAddressType;
exports.BitcoinAddressType = BitcoinAddressType;
(function (BitcoinAddressType) {
Expand Down
14 changes: 7 additions & 7 deletions local-libs/keyring/cjs/utils/derive-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getEvmDerivePath = index => {
return emvPath.replace('{index}', index.toString());
};
exports.getEvmDerivePath = getEvmDerivePath;
const getBitDerivePathFunction = (proposal, slip44) => {
const getBitDerivePathFunction = (slip44, proposal) => {
const path = bitPath.replace('{proposal}', proposal.toString()).replace('{slip44}', slip44.toString());
return index => {
return path.replace('{index}', index.toString());
Expand All @@ -27,17 +27,17 @@ const getDerivePath = type => {
case 'ethereum':
return getEvmDerivePath;
case 'bitcoin-44':
return getBitDerivePathFunction(44, 0);
return getBitDerivePathFunction(0, 44);
case 'bitcoin-84':
return getBitDerivePathFunction(84, 0);
return getBitDerivePathFunction(0, 84);
case 'bitcoin-86':
return getBitDerivePathFunction(86, 0);
return getBitDerivePathFunction(0, 86);
case 'bittest-44':
return getBitDerivePathFunction(44, 1);
return getBitDerivePathFunction(1, 44);
case 'bittest-84':
return getBitDerivePathFunction(84, 1);
return getBitDerivePathFunction(1, 84);
case 'bittest-86':
return getBitDerivePathFunction(86, 1);
return getBitDerivePathFunction(1, 86);
default:
return () => '';
}
Expand Down
1 change: 1 addition & 0 deletions local-libs/keyring/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
"@polkadot/util-crypto": "^12.2.1",
"bcryptjs": "^2.4.3",
"bignumber.js": "^9.1.2",
"bip322-js": "^2.0.0",
"bitcoinjs-lib": "^6.1.5",
"bitcoinjs-message": "^2.2.0",
"ecpair": "^2.1.0",
Expand Down
27 changes: 15 additions & 12 deletions local-libs/keyring/pair/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright 2017-2022 @polkadot/keyring authors & contributors
// SPDX-License-Identifier: Apache-2.0

import { Signer } from 'bip322-js';
import * as bitcoin from 'bitcoinjs-lib';
import { sign as bitcoinSignMessage } from 'bitcoinjs-message';
import { ECPairFactory } from 'ecpair';
import SimpleKeyring from 'eth-simple-keyring';
import * as ecc from 'tiny-secp256k1';
import { hexAddPrefix, hexStripPrefix, objectSpread, u8aConcat, u8aEmpty, u8aEq, u8aToHex, u8aToU8a } from '@polkadot/util';
import { hexAddPrefix, hexStripPrefix, objectSpread, u8aConcat, u8aEmpty, u8aEq, u8aToHex, u8aToString, u8aToU8a } from '@polkadot/util';
import { blake2AsU8a, ethereumEncode, hdEthereum, keyExtractPath, mnemonicToLegacySeed, secp256k1Compress, signatureVerify, sr25519VrfSign, sr25519VrfVerify } from '@polkadot/util-crypto';
import { entropyToMnemonic } from '@polkadot/util-crypto/mnemonic/bip39';
import { getDerivePath, keyFromPath, TYPE_ADDRESS, TYPE_FROM_SEED, TYPE_PREFIX, TYPE_SIGNATURE } from "../utils/index.js";
Expand Down Expand Up @@ -94,13 +94,13 @@ export function createPair({
const encodeAddress = () => {
const raw = TYPE_ADDRESS[type](publicKey);
const bitNetwork = ['bitcoin-44', 'bitcoin-84', 'bitcoin-86'].includes(type) ? bitcoin.networks.bitcoin : ['bittest-44', 'bittest-84', 'bittest-86'].includes(type) ? bitcoin.networks.testnet : bitcoin.networks.regtest;
let dataKey;

/**
* With bitcoin accounts, some attached account have no public key (only address).
* In this case, public key is the hash of result after decoded address.
* Add `noPublicKey` in metadata for this case.
*/
let dataKey;
if (meta.noPublicKey) {
dataKey = 'hash';
} else {
Expand Down Expand Up @@ -301,34 +301,37 @@ export function createPair({
type
}, derived, meta, null);
},
signMessage: (message, compressed, options) => {
signMessage: message => {
if (isLocked(secretKey)) {
throw new Error('Cannot encrypt with a locked key pair');
}
const _message = typeof message === 'string' ? message : Buffer.from(message);
const _message = typeof message === 'string' ? message : u8aToString(message);
const address = encodeAddress();
const _pair = ECPair.fromPrivateKey(Buffer.from(secretKey));
const wif = _pair.toWIF();

// Sign the message
const signature = bitcoinSignMessage(_message, Buffer.from(secretKey), compressed, options);
return signature.toString('base64');
const signature = Signer.sign(wif, address, _message);
return typeof signature === 'string' ? signature : signature.toString('base64');
},
signTransaction: (transaction, indexes) => {
signTransaction: (psbt, indexes, sighashTypes, tapLeafHashToSign) => {
if (isLocked(secretKey)) {
throw new Error('Cannot encrypt with a locked key pair');
}
if (!transaction) {
if (!psbt) {
throw new Error('Not found sign method');
}
const pair = ECPair.fromPrivateKey(Buffer.from(secretKey));
const isTaproot = ['bitcoin-86', 'bittest-86'].includes(type);
for (const index of indexes) {
if (isTaproot) {
const tweakedSigner = pair.tweak(bitcoin.crypto.taggedHash('TapTweak', toXOnly(pair.publicKey)));
transaction.signTaprootInput(index, tweakedSigner);
psbt.signTaprootInput(index, tweakedSigner, tapLeafHashToSign, sighashTypes);
} else {
transaction.signInput(index, pair);
psbt.signInput(index, pair, sighashTypes);
}
}
return transaction;
return psbt;
},
get output() {
return output || Buffer.from([]);
Expand Down
5 changes: 2 additions & 3 deletions local-libs/keyring/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { HexString } from '@polkadot/util/types';
import type { EncryptedJson, Keypair, Prefix } from '@polkadot/util-crypto/types';
import { TypedTransaction } from '@ethereumjs/tx';
import { Psbt as BitcoinTransaction } from 'bitcoinjs-lib';
import { SignatureOptions } from 'bitcoinjs-message';
/**
*
*
Expand Down Expand Up @@ -58,8 +57,8 @@ export interface SubstrateSigner {
}
export interface BitcoinSigner {
derive: (index: number, meta?: KeyringPair$Meta) => KeyringPair;
signMessage: (message: HexString | string | Uint8Array, compressed?: boolean, options?: SignatureOptions) => string;
signTransaction: (transaction: BitcoinTransaction, indexes: number[]) => BitcoinTransaction;
signMessage: (message: HexString | string | Uint8Array) => string;
signTransaction: (transaction: BitcoinTransaction, indexes: number[], sighashTypes?: number[], tapLeafHashToSign?: Buffer | undefined) => BitcoinTransaction;
output: Buffer;
internalPubkey: Buffer;
}
Expand Down
Loading

0 comments on commit e55094d

Please sign in to comment.