Skip to content
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

Allow ext keys #3

Merged
merged 7 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/addresstype.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <attributes.h>
#include <pubkey.h>
#include <script/script.h>
#include <silentpaymentkey.h>
#include <uint256.h>
#include <util/hash_type.h>

Expand Down Expand Up @@ -121,6 +122,20 @@ struct V0SilentPaymentDestination
CPubKey m_scan_pubkey;
CPubKey m_spend_pubkey;

V0SilentPaymentDestination() = default;

V0SilentPaymentDestination(const CPubKey& scan_pubkey, const CPubKey& spend_pubkey) : m_scan_pubkey(scan_pubkey), m_spend_pubkey(spend_pubkey) {};

V0SilentPaymentDestination(const SpPubKey& sppubkey) {
m_scan_pubkey = sppubkey.scanKey.GetPubKey();
m_spend_pubkey = sppubkey.spendKey;
}

V0SilentPaymentDestination(const SpKey& spkey) {
m_scan_pubkey = spkey.scanKey.GetPubKey();
m_spend_pubkey = spkey.spendKey.GetPubKey();
}

friend bool operator==(const V0SilentPaymentDestination& a, const V0SilentPaymentDestination& b) {
if (a.m_scan_pubkey != b.m_scan_pubkey) return false;
if (a.m_spend_pubkey != b.m_spend_pubkey) return false;
Expand Down
4 changes: 4 additions & 0 deletions src/rpc/output_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ static RPCHelpMan deriveaddresses()

addresses.push_back(EncodeDestination(dest));
}

for (const auto& sppubkey_pair: provider.sppubkeys) {
addresses.push_back(EncodeDestination(V0SilentPaymentDestination(sppubkey_pair.second)));
}
Comment on lines +289 to +291
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in 06281a3:

silent payments aren't ranged, so not clear to me how this line would be hit if calling deriveaddresses with an sp descriptor?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code always runs at least once. See line 268

}

// This should not be possible, but an assert seems overkill:
Expand Down