-
Notifications
You must be signed in to change notification settings - Fork 7
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
Feature/wallet preparetx #24
Conversation
@akekeke |
5b12cef
to
4416e31
Compare
Sorry this PR is so large ><; ListUnspent() is longer than I thought it would be. This PR:
No test is written for ListUnspent() yet |
aa22de4
to
a560051
Compare
internal/wallet/wallet.go
Outdated
@@ -111,7 +112,7 @@ func Create(db walletdb.DB, params *chaincfg.Params, seed, pubPass, | |||
|
|||
// Open loads a wallet from the passed db and public pass phrase. | |||
func Open(db walletdb.DB, pubPass []byte, | |||
params *chaincfg.Params) (Wallet, error) { | |||
params *chaincfg.Params) (*wallet, error) { |
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.
I think this function should return a struct instead of an interface, because the wallet struct already fulfills the Wallet interface.
What do you think? @Jwata
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.
As golint tells us, caller doesn't know about wallet because it's private.
exported func Open returns unexported type *wallet.wallet, which can be annoying to use
Related to this discussion.
golang/lint#210
This PR:
|
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.
I will review more closely later, but leave some comments.
It seems better to work together to finish wallet task as it's getting complicated to manage managers...
internal/wallet/wallet.go
Outdated
@@ -111,7 +112,7 @@ func Create(db walletdb.DB, params *chaincfg.Params, seed, pubPass, | |||
|
|||
// Open loads a wallet from the passed db and public pass phrase. | |||
func Open(db walletdb.DB, pubPass []byte, | |||
params *chaincfg.Params) (Wallet, error) { | |||
params *chaincfg.Params) (*wallet, error) { |
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.
As golint tells us, caller doesn't know about wallet because it's private.
exported func Open returns unexported type *wallet.wallet, which can be annoying to use
Related to this discussion.
golang/lint#210
internal/wallet/address.go
Outdated
"github.com/btcsuite/btcutil" | ||
"github.com/btcsuite/btcwallet/waddrmgr" | ||
"github.com/btcsuite/btcwallet/walletdb" | ||
) | ||
|
||
func (w *wallet) NewPubkey() (pub *btcec.PublicKey, err error) { | ||
// TODO: generate new pubkey and address using newAddress | ||
_, err = w.newAddress(waddrmgr.KeyScopeBIP0084, []byte{}, uint32(1), uint32(1)) | ||
mAddrs, err := w.newAddress(waddrmgr.KeyScopeBIP0084, w.privatePassphrase, uint32(1), uint32(1)) |
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.
I still wonder why you need private key, though.
I guess the manager already is unlocked? so you don't need to unlock it everytime you write.
https://github.com/btcsuite/btcwallet/blob/c4dd27e481f9801866cf5226bfe532084772ec2a/wallet/wallet.go#L2830
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.
I guess that a private kay was necessary for creating managers, but not for modifying records.
internal/wallet/utxo.go
Outdated
addrmgrNs := tx.ReadBucket(waddrmgrNamespaceKey) | ||
txmgrNs := tx.ReadBucket(wtxmgrNamespaceKey) | ||
|
||
syncBlock := w.manager.SyncedTo() |
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.
Does the waddmgr do some block downloading task?
I though it just manages addresses and priv/pub keys of them.
internal/wallet/test_util.go
Outdated
@@ -48,14 +48,14 @@ func setupDB(t *testing.T) (db walletdb.DB, tearDownFunc func()) { | |||
return | |||
} | |||
|
|||
func setupWallet(t *testing.T) (tearDownFunc func(), w Wallet) { | |||
func setupWallet(t *testing.T) (tearDownFunc func(), w Wallet, db walletdb.DB) { |
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.
Some tests need to access the wallet's db directly, so that's why I added db as one of returned values
internal/wallet/wallet.go
Outdated
|
||
Manager() *waddrmgr.Manager | ||
TxStore() *wtxmgr.Store |
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.
Added getter functions so functions that use the Wallet interface have access to wallet's manager and txStore
This PR:
|
72f1c30
to
8b77ef5
Compare
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.
LGTM. Let's finish in next PR.
WIP
This closes #6