mirror of
https://github.com/aljazceru/ark.git
synced 2026-01-29 00:04:25 +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:
@@ -32,6 +32,16 @@ var (
|
||||
Usage: "address gap limit for wallet restoration",
|
||||
Value: 100,
|
||||
}
|
||||
amountFlag = &cli.UintFlag{
|
||||
Name: "amount",
|
||||
Usage: "amount of the note in satoshis",
|
||||
Required: true,
|
||||
}
|
||||
quantityFlag = &cli.UintFlag{
|
||||
Name: "quantity",
|
||||
Usage: "quantity of notes to create",
|
||||
Value: 1,
|
||||
}
|
||||
)
|
||||
|
||||
// commands
|
||||
@@ -46,6 +56,7 @@ var (
|
||||
walletUnlockCmd,
|
||||
walletAddressCmd,
|
||||
walletBalanceCmd,
|
||||
createNoteCmd,
|
||||
),
|
||||
}
|
||||
walletStatusCmd = &cli.Command{
|
||||
@@ -75,6 +86,12 @@ var (
|
||||
Usage: "Get the wallet balance",
|
||||
Action: walletBalanceAction,
|
||||
}
|
||||
createNoteCmd = &cli.Command{
|
||||
Name: "note",
|
||||
Usage: "Create a credit note",
|
||||
Action: createNoteAction,
|
||||
Flags: []cli.Flag{amountFlag, quantityFlag},
|
||||
}
|
||||
)
|
||||
|
||||
var timeout = time.Minute
|
||||
@@ -208,6 +225,39 @@ func walletBalanceAction(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func createNoteAction(ctx *cli.Context) error {
|
||||
baseURL := ctx.String("url")
|
||||
amount := ctx.Uint("amount")
|
||||
quantity := ctx.Uint("quantity")
|
||||
var macaroon string
|
||||
if !ctx.Bool("no-macaroon") {
|
||||
macaroonPath := ctx.String("macaroon-path")
|
||||
mac, err := getMacaroon(macaroonPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
macaroon = mac
|
||||
}
|
||||
tlsCertPath := ctx.String("tls-cert-path")
|
||||
if strings.Contains(baseURL, "http://") {
|
||||
tlsCertPath = ""
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/v1/admin/note", baseURL)
|
||||
body := fmt.Sprintf(`{"amount": %d, "quantity": %d}`, amount, quantity)
|
||||
|
||||
notes, err := post[[]string](url, body, "notes", macaroon, tlsCertPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, note := range notes {
|
||||
fmt.Println(note)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func post[T any](url, body, key, macaroon, tlsCert string) (result T, err error) {
|
||||
tlsConfig, err := getTLSConfig(tlsCert)
|
||||
if err != nil {
|
||||
|
||||
@@ -60,28 +60,29 @@ func mainAction(_ *cli.Context) error {
|
||||
}
|
||||
|
||||
appConfig := &appconfig.Config{
|
||||
EventDbType: cfg.EventDbType,
|
||||
DbType: cfg.DbType,
|
||||
DbDir: cfg.DbDir,
|
||||
DbMigrationPath: cfg.DbMigrationPath,
|
||||
EventDbDir: cfg.DbDir,
|
||||
RoundInterval: cfg.RoundInterval,
|
||||
Network: cfg.Network,
|
||||
SchedulerType: cfg.SchedulerType,
|
||||
TxBuilderType: cfg.TxBuilderType,
|
||||
BlockchainScannerType: cfg.BlockchainScannerType,
|
||||
WalletAddr: cfg.WalletAddr,
|
||||
RoundLifetime: cfg.RoundLifetime,
|
||||
UnilateralExitDelay: cfg.UnilateralExitDelay,
|
||||
EsploraURL: cfg.EsploraURL,
|
||||
NeutrinoPeer: cfg.NeutrinoPeer,
|
||||
BitcoindRpcUser: cfg.BitcoindRpcUser,
|
||||
BitcoindRpcPass: cfg.BitcoindRpcPass,
|
||||
BitcoindRpcHost: cfg.BitcoindRpcHost,
|
||||
BoardingExitDelay: cfg.BoardingExitDelay,
|
||||
UnlockerType: cfg.UnlockerType,
|
||||
UnlockerFilePath: cfg.UnlockerFilePath,
|
||||
UnlockerPassword: cfg.UnlockerPassword,
|
||||
EventDbType: cfg.EventDbType,
|
||||
DbType: cfg.DbType,
|
||||
DbDir: cfg.DbDir,
|
||||
DbMigrationPath: cfg.DbMigrationPath,
|
||||
EventDbDir: cfg.DbDir,
|
||||
RoundInterval: cfg.RoundInterval,
|
||||
Network: cfg.Network,
|
||||
SchedulerType: cfg.SchedulerType,
|
||||
TxBuilderType: cfg.TxBuilderType,
|
||||
WalletAddr: cfg.WalletAddr,
|
||||
RoundLifetime: cfg.RoundLifetime,
|
||||
UnilateralExitDelay: cfg.UnilateralExitDelay,
|
||||
EsploraURL: cfg.EsploraURL,
|
||||
NeutrinoPeer: cfg.NeutrinoPeer,
|
||||
BitcoindRpcUser: cfg.BitcoindRpcUser,
|
||||
BitcoindRpcPass: cfg.BitcoindRpcPass,
|
||||
BitcoindRpcHost: cfg.BitcoindRpcHost,
|
||||
BoardingExitDelay: cfg.BoardingExitDelay,
|
||||
UnlockerType: cfg.UnlockerType,
|
||||
UnlockerFilePath: cfg.UnlockerFilePath,
|
||||
UnlockerPassword: cfg.UnlockerPassword,
|
||||
NostrDefaultRelays: cfg.NostrDefaultRelays,
|
||||
NoteUriPrefix: cfg.NoteUriPrefix,
|
||||
}
|
||||
svc, err := grpcservice.NewService(svcConfig, appConfig)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user