-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat(core): add transaction builder for signing transactions with mul… #362
Conversation
…tiple private keys
import { blake2b, hexToBytes, bytesToHex, PERSONAL } from '@nervosnetwork/ckb-sdk-utils' | ||
import Address from './address' | ||
|
||
export default (addrObj: Address, transactionHash: string, witness: string = '') => { |
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.
signWitness
is a action, so maybe it's not appropriate for file name.
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.
It's better to keep the name the same as the function exported by default in js.
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.
OK
s.update(hexToBytes(transactionHash)) | ||
s.update(witnessBytes) | ||
const message = `0x${s.digest('hex')}` | ||
const data = [...hexToBytes(addrObj.signRecoverable(message)), ...witnessBytes] |
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.
Why signRecoverable
function is in Address
module ?
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.
In fact, the Address
class derives from the ECPairs
class, which is used to generate key pairs, thus the address object is able to sign messages.
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.
OK. I just think Address
and ECPairs
are different modules, and signRecoverable
can be in ECPairs
but not Address
.
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.
Agree. I have been wanting to propose changing Address
's base type for long time. It's not great to let developer know that address is an ECPairs
.
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.
Please plan this in another feature branch.
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.
Gotcha
} | ||
} | ||
|
||
public updateTransactionHash = () => { |
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.
When and where updateTransactionHash
function will be called? I don't catch it and I think it could be private.
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.
It will be called automatically on calling signInput
if the builder.hash
is empty. But it should be able to update the hash manually when the raw transaction is updated and the hash is calculated already.
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.
OK. I think sometimes we support more interfaces maybe not a good thing.
…tiple private keys