-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wallet improvements #180
Wallet improvements #180
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. In addition to the few comments I left, there are some public methods in the AbstractHDWallet
class missing explicit public modifier
src/wallet/hdwallet.ts
Outdated
addrIndex++; | ||
// put a hard limit on the number of addresses to derive | ||
if (addrIndex - startingIndex > MAX_ADDRESS_DERIVATION_ATTEMPTS) { | ||
throw new Error(`Failed to derive a valid address for the zone ${zone} after MAX_ADDRESS_DERIVATION_ATTEMPTS attempts.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's log the actual value of MAX_ADDRESS_DERIVATION_ATTEMPTS
by wrapping in ${}
block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/wallet/qi-hdwallet.ts
Outdated
@@ -18,42 +21,40 @@ type OutpointInfo = { | |||
account?: number; | |||
}; | |||
|
|||
export class QiHDWallet extends HDWallet { | |||
export class QiHDWallet extends AbstractHDWallet { | |||
|
|||
protected static _GAP_LIMIT: number = 20; | |||
|
|||
protected static _cointype: number = 969; | |||
|
|||
protected static _parentPath = `m/44'/${this._cointype}'`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove static _parentPath
var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
const txobj = QiTransaction.from(<TransactionLike>tx); | ||
if (!txobj.txInputs || txobj.txInputs.length == 0 || !txobj.txOutputs) | ||
throw new Error('Invalid UTXO transaction, missing inputs or outputs'); | ||
public importOutpoints(outpoints: OutpointInfo[]): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update zone string on OutpointInfo
type and validate OutpointInfo[]
values are valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
public async signTransaction(tx: QiTransactionRequest): Promise<string> { | ||
const txobj = QiTransaction.from(<TransactionLike>tx); | ||
if (!txobj.txInputs || txobj.txInputs.length == 0 || !txobj.txOutputs) | ||
throw new Error('Invalid UTXO transaction, missing inputs or outputs'); | ||
|
||
const hash = keccak_256(txobj.unsignedSerialized); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace keccak_256
with keccak256
exported from crypto dir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current keccak_256
is imported directly from @noble/hashes/sha3
. Even though is the same algorithm used by the keccak function in crypto dir, the internnaly exported keccak256
has a different signature.
Let's address this suggestion on a different PR? The code needs a little refactoring, and mainly testing compatibility with the keccak256
from crypto dir.
95be832
to
dc7838a
Compare
Improvements to Qi and Quai HD wallets: