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:
Louis Singer
2024-11-15 19:07:33 +01:00
committed by GitHub
parent 963f5d89e6
commit ff96524f22
94 changed files with 6377 additions and 1230 deletions

View File

@@ -3,6 +3,7 @@ package application
import (
"context"
"github.com/ark-network/ark/common/note"
"github.com/ark-network/ark/server/internal/core/ports"
)
@@ -47,6 +48,7 @@ type AdminService interface {
GetRounds(ctx context.Context, after int64, before int64) ([]string, error)
GetWalletAddress(ctx context.Context) (string, error)
GetWalletStatus(ctx context.Context) (*WalletStatus, error)
CreateNotes(ctx context.Context, amount uint32, quantity int) ([]string, error)
}
type adminService struct {
@@ -179,3 +181,24 @@ func (a *adminService) GetWalletStatus(ctx context.Context) (*WalletStatus, erro
IsSynced: status.IsSynced(),
}, nil
}
func (a *adminService) CreateNotes(ctx context.Context, value uint32, quantity int) ([]string, error) {
notes := make([]string, 0, quantity)
for i := 0; i < quantity; i++ {
data, err := note.New(value)
if err != nil {
return nil, err
}
noteHash := data.Hash()
signature, err := a.walletSvc.SignMessage(ctx, noteHash)
if err != nil {
return nil, err
}
note := data.ToNote(signature)
notes = append(notes, note.String())
}
return notes, nil
}