Giter Club home page Giter Club logo

theborakompanioni / bitcoin-spring-boot-starter Goto Github PK

View Code? Open in Web Editor NEW
59.0 6.0 16.0 12.16 MB

Write enterprise Bitcoin applications with Spring Boot. Starter projects with multiple Bitcoin related modules that you can include in your application.

Home Page: https://theborakompanioni.github.io/bitcoin-spring-boot-starter

License: Apache License 2.0

Java 97.72% HTML 0.71% CSS 0.95% Shell 0.07% JavaScript 0.54%
bitcoin lightning spring-boot java spring cln lnd

bitcoin-spring-boot-starter's People

Contributors

danielweigl avatar johnzweng avatar jump-kick avatar rvullriede avatar theborakompanioni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bitcoin-spring-boot-starter's Issues

make upstream dependencies in autoconfigure modules optional

The dependencies should be included by downstream consumers, hence, they should be optional. Starters will include them nonetheless!

Currently, following autoconfigure modules have their dependencies non-optionally included:

  • bitcoin-jsonrpc-client-autoconfigure
  • cln-grpc-client-autoconfigure
  • lnd-grpc-client-autoconfigure

Login successful but user not authenticated

Sorry i think its not a but more a request for help. I think I'm close to have something working! and the blog post is close to be done too.

I'm stuck at this step: login page is displayed, I scan the QR code, my wallet says "authentication success", but I'm stuck on the login page, no redirect and if I manually go back to home page where there is this thymeleaf code:

<p sec:authentication="name"></p>

It says anonymous user;

When I check the logs, I can the user is crated and the SecurityContextHolder is set:

s.s.LnurlAuthSessionAuthenticationFilter : got lnurl-auth session migration request for k1 '0f0dbde709f33c8879093987ba53e22eb5eaa2aa0f7acdfd227f598bd01957e5'
o.r.e.c.s.u.UserServiceImplementation    : Finding the paired linking key for k1 0f0dbde709f33c8879093987ba53e22eb5eaa2aa0f7acdfd227f598bd01957e5
o.r.e.c.s.u.UserServiceImplementation    : Linking key not found

.s.w.LnurlAuthWalletAuthenticationFilter : got lnurl-auth wallet authentication request for k1 '55c5460f801a6241d42ac21f86f15d4bf7d176e4acd660e58bff988632e51719'
o.r.e.c.s.u.UserServiceImplementation    : Creating the user for the linking key: 02ed9953f5e3a7a79b943ffa333f08bdfe42373199b21b91a77511d384344bd1c2
o.r.e.c.s.u.UserServiceImplementation    : Creating a user with username: 02ed9953f5e3a7a79b943ffa333f08bdfe42373199b21b91a77511d384344bd1c2
o.r.e.c.s.u.UserServiceImplementation    : User created: User(id=3, userId=b486f731-1335-4d0c-ad5c-1ca509a166aa, username=02ed9953f5e3a7a79b943ffa333f08bdfe42373199b21b91a77511d384344bd1c2, role=USER)
.s.w.LnurlAuthWalletAuthenticationFilter : Set SecurityContextHolder to LnurlAuthWalletToken [Principal=02ed9953f5e3a7a79b943ffa333f08bdfe42373199b21b91a77511d384344bd1c2, Credentials=[PROTECTED], Authenticated=true, Details=org.springframework.security.core.userdetails.User [Username=02ed9953f5e3a7a79b943ffa333f08bdfe42373199b21b91a77511d384344bd1c2, Password=[PROTECTED], Enabled=true, AccountNonExpired=true, CredentialsNonExpired=true, AccountNonLocked=true, Granted Authorities=[USER]], Granted Authorities=[USER]]
rlAuthWalletAuthenticationSuccessHandler : Received successful lnurl-auth wallet request of user '02ed9953f5e3a7a79b943ffa333f08bdfe42373199b21b91a77511d384344bd1c2'

s.s.LnurlAuthSessionAuthenticationFilter : got lnurl-auth session migration request for k1 '94b1f3fa2cfcea4ece82b193375f0d5e51b7c83c0d2817657da2f479f7a5e3b5'
o.r.e.c.s.u.UserServiceImplementation    : Finding the paired linking key for k1 94b1f3fa2cfcea4ece82b193375f0d5e51b7c83c0d2817657da2f479f7a5e3b5
o.r.e.c.s.u.UserServiceImplementation    : Linking key not found

s.s.LnurlAuthSessionAuthenticationFilter : got lnurl-auth session migration request for k1 '93a030bff5a07fd26930b1ec2d8535e3a6f15531627969e967b2fb25406657ed'
o.r.e.c.s.u.UserServiceImplementation    : Finding the paired linking key for k1 93a030bff5a07fd26930b1ec2d8535e3a6f15531627969e967b2fb25406657ed
o.r.e.c.s.u.UserServiceImplementation    : Linking key not found

I'm using 0.12.0 and this is what I did:

DatabaseK1Manager

I created a DatabaseK1Manager that implements your K1Manager but stores the k1 in database.

UserLnurlAuthKey

I added a domain object named UserLnurlAuthKey linked to the user. It has a linkingKey and a k1 fields.

Implements LnurlAuthPairingService

I re-used my user service to implement LnurlAuthPairingService

pairK1WithLinkingKey : If the linking key is not already in our database, I create a new user, and it's UserLnurlAuthKey object else I only
update the k1.

findPairedLinkingKeyByK1 : Looking at UserLnurlAuthKey, I search by k1 and returns the linking key if found.

Implements UserDetailsService

I re-used my user service to implement UserDetailsService

loadUserByUsername : I search a user by its linking key (I saw you search by username in your example but i may let the user change its username).

lnurlAuthFactory

i copied on what you and change the url everytime to nrgok https url:
lnurlAuthFactory

securityConfiguration

I did, I think, the same thing as you: SecurityConfiguration

Blog post review

Hi!

Thanks again for your help.

I finished the blog post; Do you thing you could take a look at it before I publish it?
I don't want people to get the wrong idea about your project.
https://github.com/royllo/explorer/blob/development/docs/design/lnurl-auth/README.md

I have one last question:

K1 exchange
I read in the documentation that the wallet will call the server URL login with this:
sig=<hex(sign(utf8ToBytes(k1), linkingPrivKey))>&key=<hex(linkingKey)>

From what I see, the server will receive the signed k& and the public linking key.
How do you, on the server side, make the link between the k1 your provided and the signed k1 you received ?

Tor new IP on each request or at will

Is your feature request related to a problem? Please describe.
I want to use this Tor library to make requests to single/similar URL multiple times from different IP.
Each time the URL will be called, it requires new IP since the service that will be accessed limits usage per IP.
What is not required for this to work is speed. If i were to make 10 requests to the URL it would be fine if accessing all those took ~1-2 minutes.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Currently this library or it's dependencies does not provide a way to restart Tor connection in runtime without killing the Tor process.

Describe the solution you'd like
I really like the solution i've seen used in python stem library.
https://stem.torproject.org/faq.html#how-do-i-reload-my-torrc

from stem import Signal
from stem.control import Controller

with Controller.from_port(port = 9051) as controller:
  controller.authenticate()
  controller.signal(Signal.HUP)

As the documentation states, this can be achieved via sending a singla RELOAD: HUP. https://github.com/torproject/torspec/blob/main/control-spec.txt

A clear and concise description of what you want to happen.
Obtain new IP address.

Describe alternatives you've considered

  • Abillity to call some function/method tor.reload() to obtain new IP address.
  • Or abillity to create new instance of Tor Controller without killing it's Tor process to obtain new IP address like the python stem library is able to do..

Additional context
I tried sending the RELOAD signal with local build of com.github.bisq-network.netlayer:tor, but that only closed Tor circuits and the Tor Socks port got closed as well (without opening a new one).
I am not exactly sure what should be done in the terms of this/dependant java implementations to open new Tor Socks port.
Maybe my attempt with the RELOAD was wrong in the first place, but it works fine here: https://github.com/setnicka/ulozto-downloader/blob/0e3b810f7676f543bf403f2f6b998c9ea02fb893/uldlib/torrunner.py#L59.

I also tried using NEWNYM, but that does not provide deterministic outcome, since the new circuits provided can ultimately have the same IP or the signal is ignored by Tor at some point.

Error when only adding the dependency

If I only add the dependency to my project (without any modification):

<dependency>
   <groupId>io.github.theborakompanioni</groupId>
   <artifactId>spring-lnurl-auth-starter</artifactId>
   <version>${bitcoin-spring-boot-starter.version}</version>
</dependency>

And I run my existing tests, I get this error:

***************************
APPLICATION FAILED TO START
***************************
Description:
The dependencies of some of the beans in the application context form a cycle:
┌──->──┐
|  k1Manager defined in class path resource [org/tbk/spring/lnurl/config/K1AutoConfiguration.class]
└──<-──┘

If I add this in any @Configuration class, it works:

@Bean
K1Manager k1Manager() {
   return new SimpleK1Manager();
}

I don't have this problem with other bean in your spring boot starter so maybe it's a configuration issue on your side?
This bug is very very very minor so no problem if not corrected.

For information, my project is a also a spring boot starter.

cln: add ssl context to auto config

Create SslContext for cln grpc client.

  • probably need to have a hard dependency on io.grpc:grpc-netty-shaded (see grpc/grpc-java#3556 - still not resolved? Needs investigation; similar to how Lightningj is doing it (used in lnd client module))

Bonus: Add AutoConfiguration for client when ClnTestcontainer bean is present (only when in regtest and optionally disable with flag)

Use JCache instead of guava caches

Is your feature request related to a problem? Please describe.

Spring Boot Actuator has nice support for Hazelcast, Caffeine, Ehcache, Redis and JCache-based implementations, but not guava. In order to deliver automatic metrics for all caches, we would have to switch to one of these libraries.

Describe the solution you'd like

Automatic cache and cache metric handling by spring boot.

Describe alternatives you've considered

Writing boilerplate code for all guava caches..

Additional context

See classes

  • org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration
  • org.springframework.boot.actuate.metrics.cache.JCacheCacheMeterBinderProvider
  • org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsAutoConfiguration

Debug message not clear in InMemoryK1Cache

Expected behavior

I'm trying to implement your spring boot starter; as I'm having issues, I added logs:

Just after starting, I go the login page and try to log with my wallet :

2024-01-22T21:23:14.690+01:00  INFO 5018 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path ''
2024-01-22T21:23:14.701+01:00  INFO 5018 --- [  restartedMain] org.royllo.explorer.web.WebApplication   : Started WebApplication in 8.914 seconds (process running for 9.551)
2024-01-22T21:23:14.710+01:00  INFO 5018 --- [oyllo-process-1] r.e.c.s.s.StatisticServiceImplementation : Clearing global statistics cache.
2024-01-22T21:23:17.534+01:00  INFO 5018 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2024-01-22T21:23:17.534+01:00  INFO 5018 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2024-01-22T21:23:17.536+01:00  INFO 5018 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms
2024-01-22T21:23:34.541+01:00 DEBUG 5018 --- [nio-8080-exec-1] s.s.LnurlAuthSessionAuthenticationFilter : got lnurl-auth session migration request for k1 'd4f067cf72b94baddac1b3856b231669c3239d59cce95ef260da58363fb01822'
2024-01-22T21:23:37.636+01:00 DEBUG 5018 --- [nio-8080-exec-2] s.s.LnurlAuthSessionAuthenticationFilter : got lnurl-auth session migration request for k1 'd4f067cf72b94baddac1b3856b231669c3239d59cce95ef260da58363fb01822'
2024-01-22T21:23:40.715+01:00 DEBUG 5018 --- [nio-8080-exec-4] s.s.LnurlAuthSessionAuthenticationFilter : got lnurl-auth session migration request for k1 'd4f067cf72b94baddac1b3856b231669c3239d59cce95ef260da58363fb01822'
2024-01-22T21:23:43.791+01:00 DEBUG 5018 --- [nio-8080-exec-3] s.s.LnurlAuthSessionAuthenticationFilter : got lnurl-auth session migration request for k1 'd4f067cf72b94baddac1b3856b231669c3239d59cce95ef260da58363fb01822'
2024-01-22T21:23:46.873+01:00 DEBUG 5018 --- [nio-8080-exec-5] s.s.LnurlAuthSessionAuthenticationFilter : got lnurl-auth session migration request for k1 'd4f067cf72b94baddac1b3856b231669c3239d59cce95ef260da58363fb01822'
2024-01-22T21:23:49.960+01:00 DEBUG 5018 --- [nio-8080-exec-7] s.s.LnurlAuthSessionAuthenticationFilter : got lnurl-auth session migration request for k1 'd4f067cf72b94baddac1b3856b231669c3239d59cce95ef260da58363fb01822'
2024-01-22T21:23:53.036+01:00 DEBUG 5018 --- [nio-8080-exec-8] s.s.LnurlAuthSessionAuthenticationFilter : got lnurl-auth session migration request for k1 'd4f067cf72b94baddac1b3856b231669c3239d59cce95ef260da58363fb01822'
2024-01-22T21:23:53.057+01:00 DEBUG 5018 --- [nio-8080-exec-6] .s.w.LnurlAuthWalletAuthenticationFilter : got lnurl-auth wallet authentication request for k1 'd4f067cf72b94baddac1b3856b231669c3239d59cce95ef260da58363fb01822'
2024-01-22T21:23:53.068+01:00 DEBUG 5018 --- [nio-8080-exec-6] org.tbk.lnurl.auth.InMemoryK1Cache       : Remove k1 'org.tbk.lnurl.simple.auth.SimpleK1@5be9b6ad' from in-memory k1 cache: EXPLICIT
2024-01-22T21:23:53.069+01:00 DEBUG 5018 --- [nio-8080-exec-6] rlAuthWalletAuthenticationFailureHandler : Received invalid lnurl-auth request: 03b64a39161d2695add91a89f9c3440a1e4d5b4e055dd19f27208975c002575bcf

I don't understand why k1 was removed so quickly but this is not the topic of this issue, i think it would be better to know what was removed from cache instead of org.tbk.lnurl.simple.auth.SimpleK1@5be9b6ad

build: re-enable configureondemand and parallel when building

Try re-enabling gradle options configureondemand and parallel.

org.gradle.configureondemand=true
org.gradle.parallel=true

This was disabled (at least "parallel") because example/testcontainer tests sometimes failed when run in parallel.
Maybe there is workaround, see https://discuss.gradle.org/t/disabling-parallel-for-certain-tasks-only/10151/15

e.g. failing testcontainer tests

Caused by:
   org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [33125] should be listening)

e.g. but also some database errors in integration tests of example applications

Caused by:
   org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such table: customer_order)

Verify that running all tests with the below command still succeed:

./gradlew clean test integrationTest -PtestcontainerTest -PexampleTest --rerun-tasks

Also:

Add support for advanced LightningJ APIs

Right now lnd-grpc-client creates injectable beans for the sync / async versions (SynchronousLndAPI, AsynchronousLndAPI) of the main LND API.

The main LND API exposes basic LND functionalities, but LightningJ also has more advanced ones.

As per its documentation, it exposes several other API services, each with a sync + an async variant, for example:

  • Wallet Unlocker API
    • org.lightningj.lnd.wrapper.walletunlocker.SynchronousWalletUnlockerAPI
    • org.lightningj.lnd.wrapper.walletunlocker.AsynchronousWalletUnlockerAPI
  • Invoices API
    • org.lightningj.lnd.wrapper.invoices.SynchronousInvoicesAPI
    • org.lightningj.lnd.wrapper.invoices.AsynchronousInvoicesAPI
  • etc

Could you please create beans for the other ones as well?

From what I can tell it comes down to extending

  • org.tbk.lightning.lnd.grpc.LndJsonRpcClientFactoryImpl and
  • org.tbk.lightning.lnd.grpc.config.LndJsonRpcClientAutoConfiguration

Thanks.

Questions about how lnurl-auth impl works

Question
In the lnurl_auth_linking_key table you create here:

  • Why do you store the least_recently_used_k1 ? when is this data queried ?
  • Why is it the least recently used k1 instead of the most recently used k1 ?

Question
Why, in your example, do you separate LnurlAuthPairingService and WalletUserService ?
What do you think would be the problem to have WalletUserService implement LnurlAuthPairingService ?

Question
My question about spring session cookie was to know if you stored things like k1, encoded k1, or linking key in the
session ?

Question
My question about why do you store the k1 was a bit stupid. Indeed, my application needs to keep it to compare it later.
My front-end application may run on several servers. From what I understand, I need to store the k1 in the database or
in a shared cache (redis, memcached, etc.) to be able to retrieve it on all my servers.
Am I right?

Question
About the k1Manager declared by default. The only benefits from having one declared by default is to make it easier to
understand how to use the library. It's the same way Spring boot declare a default jdbc pool if you don't declare one.
It hides complexity for the newcomer.

Lnurl auth problem with latest Spring Boot

Is your feature request related to a problem? Please describe.

I use the latest Spring boot release and I try to implement lnurl auth.

Using your example, I get this error:
'apply(C)' is deprecated since version 6.2 and marked for removal

With latest spring boot release, <C extends SecurityConfigurerAdapter<O, B>> C apply(C configurer) is deprecated.
Now, the method <C extends SecurityConfigurer<O, B>> C apply(C configurer) should be used.

Describe the solution you'd like

Upgrade to latest spring boot release or tell me how I can make it work :)

SimpleLinkingKey not found when used in spring boot starter.

I'm building a Spring boot starter including spring-lnurl-auth-starter.

In my spring boot starter tests, I can do this:

LinkingKey linkingKeyTest1 = SimpleLinkingKey.fromHex("02c3b844b8104f0c1b15c507774c9ba7fc609f58f343b9b149122e944dd20c9362");`

In my spring boot starter code, I can't do the same thing:

LinkingKey linkingKeyTest1 = SimpleLinkingKey.fromHex("02c3b844b8104f0c1b15c507774c9ba7fc609f58f343b9b149122e944dd20c9362");`

because I get this error: java: package org.tbk.lnurl.simple.auth does not exist

I'm forced to add this to my POM:

<dependency>
   <groupId>io.github.theborakompanioni</groupId>
   <artifactId>lnurl-simple</artifactId>
   <version>0.11.0</version>
</dependency>

feat: expose port and network for bitcoin testcontainer

Expose and use port and network in BitcoindContainerProperties.

  • Replace properties in all config files
    e.g.
org.tbk.bitcoin.jsonrpc:
  network: regtest
  rpchost: http://localhost
  rpcport: 18443
  rpcuser: ${org.tbk.spring.testcontainer.bitcoind.rpcuser}
  rpcpassword: ${org.tbk.spring.testcontainer.bitcoind.rpcpassword}

to

org.tbk.bitcoin.jsonrpc:
  network:  ${org.tbk.spring.testcontainer.bitcoind.network}
  rpchost: http://localhost
  rpcport: ${org.tbk.spring.testcontainer.bitcoind.rpcport}
  rpcuser: ${org.tbk.spring.testcontainer.bitcoind.rpcuser}
  rpcpassword: ${org.tbk.spring.testcontainer.bitcoind.rpcpassword}

feat: externalize module `cln-grpc-client`

Keep autoconfig and starter package, but externalize core client to own repo.
Should be possible to release a new client version independently from bitcoin-spring-boot-starter.

TOR auto-publish-enabled property not honored

Expected behavior

Setting org.tbk.tor.auto-publish-enabled=false should disable auto publishing.

Actual behavior

Setting org.tbk.tor.auto-publish-enabled=false has no effect.
Application fails to configure.

Steps to reproduce the problem

  1. Set property org.tbk.tor.auto-publish-enabled=false
  2. Run Application
  3. Fail

Specifications

  • Version: 0.3.0
  • Platform: MacOS
  • Module: spring-tor-autoconfigure

implementation("io.github.theborakompanioni:spring-tor-starter:0.3.0")

Kotlin 1.6.21
Spring Boot 2.7.4
Gradle 7.5

Additional context

Log:

Caused by: java.lang.IllegalStateException: Cannot publish hidden service for application. Please specify 'server.port' or disable auto publishing with 'org.tbk.tor.auto-publish-enabled=false'
	at org.tbk.tor.spring.config.TorHiddenServiceAutoConfiguration.applicationHiddenServiceDefinition(TorHiddenServiceAutoConfiguration.java:42) ~[spring-tor-autoconfigure-0.3.0.jar:0.3.0]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.23.jar:5.3.23]
	... 84 common frames omitted

Debug autoconfiguration output:

   TorHiddenServiceAutoConfiguration#applicationHiddenServiceDefinition matched:
      - @ConditionalOnBean (types: org.springframework.boot.autoconfigure.web.ServerProperties; SearchStrategy: all) found bean 'server-org.springframework.boot.autoconfigure.web.ServerProperties'; @ConditionalOnMissingBean (names: applicationHiddenServiceDefinition; SearchStrategy: all) did not find any beans (OnBeanCondition)

It looks like @Conditional(OnAutoPublishEnabledAndServerPortSpecified.class) is not evaluated at all.

Tor Graal-VM native-image compatibility

I would like to start a discussion on making the spring-tor and dependent libraries native-image compatible.
Spring Boot 3 is going to have stable support for native-image and it can be also used in SB 2 as experimental feature.

Since Tor Spring functionality requires 3 different libraries, it would be helpful to perhaps try to add support for each library separately and try to introduce some PR in other github repos.

My use case consists of Tor and DJL + Tensorflow and maybe some other libraries.
Most of them are compatible with native-image, however Tor is not one of them and DJL seems not to work at the moment.

Using SNAPSHOT release

HI, to test your new development and close some issues, I wanted to move to 0.13.0-SNAPSHOT

I made this change to maven:

<dependency>
   <groupId>io.github.theborakompanioni</groupId>
   <artifactId>spring-lnurl-auth-starter</artifactId>
   <version>0.13.0-SNAPSHOT</version>
</dependency>

And I added:

    <repositories>
        <repository>
            <id>snapshot-repo</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

But I get this message: Dependency 'io.github.theborakompanioni:spring-lnurl-auth-starter:0.13.0-SNAPSHOT' not found
What did I get wrong?

ClassCastException when using @AuthenticationPrincipal

I have a spring boot controller with that code:

@GetMapping("/account/settings")
@PreAuthorize("isAuthenticated()")
public String displayAccountSettings(final Model model,
                                         final @AuthenticationPrincipal(errorOnInvalidType = true) UserDetails currentUser) {
        Optional<UserDTO> connectedUser = userService.getUserByUsername(currentUser.getUsername());

I get this error: java.lang.ClassCastException: 028acfe2a7c5444a5872968f628d8fc827c32f7b11761e094818ee10ceeee9c5eb is not assignable to interface org.springframework.security.core.userdetails.UserDetails

It seems your starter is not passing the userDetails but the linkingkey ?

bug: Unique constraint error in payment request example app

Error during payment evaluation in BitcoinPaymentRequestExampleApplication.

Start with ./gradlew -p examples/incubator/bitcoin-payment-request-example-application bootRun create an onchain donation on http://localhost:8080 and watch the logs:

2023-03-26T02:02:59.553Z DEBUG 74269 --- [    tbk-async-1] o.t.b.e.p.p.PaymentRequestServiceImpl    : Onchain payment request 4a9dd799-f1b1-48be-a4f2-9bc76ce570d2 has not been paid yet
2023-03-26T02:02:59.564Z  WARN 74269 --- [    tbk-async-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 19, SQLState: null
2023-03-26T02:02:59.564Z ERROR 74269 --- [    tbk-async-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : [SQLITE_CONSTRAINT_UNIQUE] A UNIQUE constraint failed (UNIQUE constraint failed: payment_request.address)
2023-03-26T02:02:59.585Z ERROR 74269 --- [    tbk-async-1] .t.b.e.p.p.BitcoinOnchainPaymentListener : Error while reevaluating payment request in loop - continue with next item

org.springframework.orm.jpa.JpaSystemException: could not execute statement
        at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:321)
        at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:233)
        at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:565)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:659)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:409)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
        at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
        at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:163)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:218)
        at org.tbk.bitcoin.example.payreq.payment.$Proxy196.save(Unknown Source)
        at org.tbk.bitcoin.example.payreq.payment.PaymentRequestServiceImpl.reevaluateOnchainBitcoinPaymentRequest(PaymentRequestServiceImpl.java:154)
        at org.tbk.bitcoin.example.payreq.payment.PaymentRequestServiceImpl.reevaluatePaymentRequest(PaymentRequestServiceImpl.java:115)
        at org.tbk.bitcoin.example.payreq.payment.BitcoinOnchainPaymentListener.onConfirmationEvent(BitcoinOnchainPaymentListener.java:34)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:577)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
        at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.hibernate.exception.GenericJDBCException: could not execute statement
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:61)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:200)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3444)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:4073)
        at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:103)
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:612)
        at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:483)
        at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:480)
        at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:329)
        at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
        at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
        at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1425)
        at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:477)
        at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2234)
        at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:1930)
        at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:439)
        at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183)
        at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281)
        at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
        at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:561)
        ... 28 common frames omitted
Caused by: org.sqlite.SQLiteException: [SQLITE_CONSTRAINT_UNIQUE] A UNIQUE constraint failed (UNIQUE constraint failed: payment_request.address)
        at org.sqlite.core.DB.newSQLException(DB.java:1135)
        at org.sqlite.core.DB.newSQLException(DB.java:1146)
        at org.sqlite.core.DB.execute(DB.java:941)
        at org.sqlite.core.DB.executeUpdate(DB.java:1010)
        at org.sqlite.jdbc3.JDBC3PreparedStatement.lambda$executeLargeUpdate$2(JDBC3PreparedStatement.java:118)
        at org.sqlite.jdbc3.JDBC3Statement.withConnectionTimeout(JDBC3Statement.java:454)
        at org.sqlite.jdbc3.JDBC3PreparedStatement.executeLargeUpdate(JDBC3PreparedStatement.java:117)
        at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:99)
        at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
        at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)
        ... 47 common frames omitted

Add testcontainer support for btc-rpc-explorer

https://github.com/janoside/btc-rpc-explorer
https://hub.docker.com/r/getumbrel/btc-rpc-explorer
Environment Sample: https://github.com/janoside/btc-rpc-explorer/blob/master/.env-sample

BTCEXP_BITCOIND_HOST=127.0.0.1
BTCEXP_BITCOIND_PORT=8332
BTCEXP_BITCOIND_USER=rpcusername
BTCEXP_BITCOIND_PASS=rpcpassword
BTCEXP_PRIVACY_MODE=true
BTCEXP_NO_INMEMORY_RPC_CACHE=true
BTCEXP_NO_RATES=true
BTCEXP_BASIC_AUTH_PASSWORD=mypassword
BTCEXP_RPC_ALLOWALL=false
BTCEXP_UI_SHOW_TOOLS_SUBHEADER=false
BTCEXP_ELECTRUMX_SERVERS=tcp://127.0.0.1:50001
BTCEXP_ADDRESS_API=electrumx
docker run -it -p 3002:3002 -e BTCEXP_NO_INMEMORY_RPC_CACHE=true -e BTCEXP_RPC_ALLOWALL=false -e BTCEXP_UI_SHOW_TOOLS_SUBHEADER=false -e BTCEXP_BASIC_AUTH_PASSWORD=any -e BTCEXP_HOST=0.0.0.0 -e BTCEXP_PRIVACY_MODE=true -e BTCEXP_BITCOIND_USER=any -e BTCEXP_BITCOIND_PASS=any -e BTCEXP_BITCOIND_HOST=172.17.0.1 -e BTCEXP_BITCOIND_PORT=33218 -e BTCEXP_ELECTRUMX_SERVERS=tcp://172.17.0.1:33226 -e BTCEXP_ADDRESS_API=electrumx getumbrel/btc-rpc-explorer:v2.1.0 

Add fee provider mempool.space to bitcoin-fee

https://mempool.space/api/v1/fees/recommended

{
  "fastestFee": 127,
  "halfHourFee": 115,
  "hourFee": 107
}

https://mempool.space/api/v1/fees/mempool-blocks

[
  {
    "blockSize": 1300829,
    "blockVSize": 991183,
    "nTx": 3166,
    "totalFees": 136194287,
    "medianFee": 126.60143562210291,
    "feeRange": [
      112.0622009569378,
      117.27569331158239,
      122.70899470899471,
      124.74191002367797,
      128.13392857142858,
      141.46205357142858,
      158.2010582010582,
      1406.476439790576
    ]
  },
  {
    "blockSize": 1118100,
    "blockVSize": 999859,
    "nTx": 2719,
    "totalFees": 105568962,
    "medianFee": 103.85477178423237,
    "feeRange": [
      100.44843049327355,
      103,
      104.92857142857143,
      112.06008337613626
    ]
  },
  [...]
]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.