ListVtxos: validate address's server public key (#386)

* ListVtxos: check server public key

* Update server/internal/core/application/covenant.go

Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
Signed-off-by: Louis Singer <41042567+louisinger@users.noreply.github.com>

* Update server/internal/core/application/covenantless.go

Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
Signed-off-by: Louis Singer <41042567+louisinger@users.noreply.github.com>

---------

Signed-off-by: Louis Singer <41042567+louisinger@users.noreply.github.com>
Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
This commit is contained in:
Louis Singer
2024-11-21 13:58:13 +01:00
committed by GitHub
parent 06dd01ecb1
commit d6b8508f6d
2 changed files with 10 additions and 0 deletions

View File

@@ -387,6 +387,11 @@ func (s *covenantService) ListVtxos(ctx context.Context, address string) ([]doma
if err != nil {
return nil, nil, fmt.Errorf("failed to decode address: %s", err)
}
if !bytes.Equal(schnorr.SerializePubKey(decodedAddress.Asp), schnorr.SerializePubKey(s.pubkey)) {
return nil, nil, fmt.Errorf("address does not match server pubkey")
}
pubkey := hex.EncodeToString(schnorr.SerializePubKey(decodedAddress.VtxoTapKey))
return s.repoManager.Vtxos().GetAllVtxos(ctx, pubkey)

View File

@@ -650,6 +650,11 @@ func (s *covenantlessService) ListVtxos(ctx context.Context, address string) ([]
if err != nil {
return nil, nil, fmt.Errorf("failed to decode address: %s", err)
}
if !bytes.Equal(schnorr.SerializePubKey(decodedAddress.Asp), schnorr.SerializePubKey(s.pubkey)) {
return nil, nil, fmt.Errorf("address does not match server pubkey")
}
pubkey := hex.EncodeToString(schnorr.SerializePubKey(decodedAddress.VtxoTapKey))
return s.repoManager.Vtxos().GetAllVtxos(ctx, pubkey)