mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-18 12:44:19 +01:00
Ark Notes (#379)
* ark credits * rename "ecash" --> "ark credit" * rework note_test.go * NewFromString * create several notes * note repo: rename "push" to "add" * RegisterInputsForNextRoundRequest: move "notes" to field #3 * use uint64 as note ID * rename to voucher * add nostr notification * nostr notification test and fixes * bump badger to 4.3 * allow npub to be registered * rename poolTxID * add default relays * Update server/internal/config/config.go Co-authored-by: Marco Argentieri <3596602+tiero@users.noreply.github.com> * fix RedeemVouchers test * notification = voucher * WASM wrappers * fix arkd voucher cmd * test_utils.go ignore gosec rule G101 * fix permissions * rename ALL to notes * add URI prefix * note.go : fix signature encoding * fix decode note.Data * Update server/internal/infrastructure/notifier/nostr/nostr.go Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com> * Update pkg/client-sdk/wasm/browser/wrappers.go Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com> * Update server/internal/infrastructure/notifier/nostr/nostr.go Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com> * rework note and entity db + sqlite implementations * NOTIFICATION_PREFIX -> NOTE_URI_PREFIX * validate NOTE_URI_PREFIX * Update defaults to convenant-less mainnet (#2) * config: defaults to convenant-less tx builder * Drop env var for blockchain scanner --------- Co-authored-by: altafan <18440657+altafan@users.noreply.github.com> * add // before URI prefix * add URI prefix in admin CreateNote * Fixes * rework nonces encoding (#4) * rework nonces encoding * add a check in Musig2Nonce decode function * musig2_test: increase number of signers to 20 * musig2.json: add a test case with a 35 leaves tree * GetEventStream REST rework * fix round phases time intervals * [SDK] Use server-side streams in rest client * Fix history * make the URI optional * Updates * Fix settled txs in history * fix e2e test * go work sync in sdk unit test * fix signMessage in btc and liquid sdk wallets --------- Co-authored-by: Marco Argentieri <3596602+tiero@users.noreply.github.com> Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
This commit is contained in:
@@ -100,6 +100,22 @@ func (a *grpcClient) RegisterInputsForNextRound(
|
||||
return resp.GetId(), nil
|
||||
}
|
||||
|
||||
func (a *grpcClient) RegisterNotesForNextRound(
|
||||
ctx context.Context, notes []string, ephemeralKey string,
|
||||
) (string, error) {
|
||||
req := &arkv1.RegisterInputsForNextRoundRequest{
|
||||
Notes: notes,
|
||||
}
|
||||
if len(ephemeralKey) > 0 {
|
||||
req.EphemeralPubkey = &ephemeralKey
|
||||
}
|
||||
resp, err := a.svc.RegisterInputsForNextRound(ctx, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return resp.GetId(), nil
|
||||
}
|
||||
|
||||
func (a *grpcClient) RegisterOutputsForNextRound(
|
||||
ctx context.Context, paymentID string, outputs []client.Output,
|
||||
) error {
|
||||
@@ -376,6 +392,45 @@ func (c *grpcClient) GetTransactionsStream(
|
||||
return eventCh, closeFn, nil
|
||||
}
|
||||
|
||||
func (a *grpcClient) SetNostrRecipient(
|
||||
ctx context.Context, nostrRecipient string, vtxos []client.SignedVtxoOutpoint,
|
||||
) error {
|
||||
req := &arkv1.SetNostrRecipientRequest{
|
||||
NostrRecipient: nostrRecipient,
|
||||
Vtxos: signedVtxosToProto(vtxos),
|
||||
}
|
||||
_, err := a.svc.SetNostrRecipient(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *grpcClient) DeleteNostrRecipient(
|
||||
ctx context.Context, vtxos []client.SignedVtxoOutpoint,
|
||||
) error {
|
||||
req := &arkv1.DeleteNostrRecipientRequest{
|
||||
Vtxos: signedVtxosToProto(vtxos),
|
||||
}
|
||||
_, err := a.svc.DeleteNostrRecipient(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func signedVtxosToProto(vtxos []client.SignedVtxoOutpoint) []*arkv1.SignedVtxoOutpoint {
|
||||
protoVtxos := make([]*arkv1.SignedVtxoOutpoint, len(vtxos))
|
||||
for i, v := range vtxos {
|
||||
protoVtxos[i] = &arkv1.SignedVtxoOutpoint{
|
||||
Outpoint: &arkv1.Outpoint{
|
||||
Txid: v.Outpoint.Txid,
|
||||
Vout: uint32(v.Outpoint.VOut),
|
||||
},
|
||||
Proof: &arkv1.OwnershipProof{
|
||||
ControlBlock: v.Proof.ControlBlock,
|
||||
Script: v.Proof.Script,
|
||||
Signature: v.Proof.Signature,
|
||||
},
|
||||
}
|
||||
}
|
||||
return protoVtxos
|
||||
}
|
||||
|
||||
func outpointsFromProto(protoOutpoints []*arkv1.Outpoint) []client.Outpoint {
|
||||
outpoints := make([]client.Outpoint, len(protoOutpoints))
|
||||
for i, o := range protoOutpoints {
|
||||
|
||||
Reference in New Issue
Block a user