mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-19 05:43:51 +01:00
Have wallet broadcast transaction for sendrawtransaction (#3578)
This commit is contained in:
parent
01617be190
commit
0a31d6a4e2
@ -795,14 +795,14 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||
val tx = Transaction(
|
||||
"020000000258e87a21b56daf0c23be8e7070456c336f7cbaa5c8757924f545887bb2abdd750000000000ffffffff838d0427d0ec650a68aa46bb0b098aea4422c071b2ca78352a077959d07cea1d0100000000ffffffff0270aaf00800000000160014d85c2b71d0060b09c9886aeb815e50991dda124d00e1f5050000000016001400aea9a2e5f0f876a588df5546e8742d1d87008f00000000")
|
||||
|
||||
(mockNode
|
||||
(mockWalletApi
|
||||
.broadcastTransaction(_: Transaction))
|
||||
.expects(tx)
|
||||
.returning(Future.unit)
|
||||
.anyNumberOfTimes()
|
||||
|
||||
val route =
|
||||
nodeRoutes.handleCommand(
|
||||
walletRoutes.handleCommand(
|
||||
ServerCommand("sendrawtransaction", Arr(Str(tx.hex))))
|
||||
|
||||
Get() ~> route ~> check {
|
||||
|
@ -3,7 +3,6 @@ package org.bitcoins.server
|
||||
import akka.actor.ActorSystem
|
||||
import akka.http.scaladsl.server.Directives._
|
||||
import akka.http.scaladsl.server._
|
||||
import org.bitcoins.commons.serializers.Picklers._
|
||||
import org.bitcoins.core.api.node.NodeApi
|
||||
import org.bitcoins.node.Node
|
||||
import org.bitcoins.rpc.client.common.BitcoindRpcClient
|
||||
@ -42,15 +41,5 @@ case class NodeRoutes(nodeApi: NodeApi)(implicit system: ActorSystem)
|
||||
nodeStopping
|
||||
}
|
||||
}
|
||||
|
||||
case ServerCommand("sendrawtransaction", arr) =>
|
||||
withValidServerCommand(SendRawTransaction.fromJsArr(arr)) {
|
||||
case SendRawTransaction(tx) =>
|
||||
complete {
|
||||
nodeApi.broadcastTransaction(tx).map { _ =>
|
||||
Server.httpSuccess(tx.txIdBE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -799,6 +799,16 @@ case class WalletRoutes(wallet: AnyDLCHDWalletApi)(implicit
|
||||
}
|
||||
}
|
||||
|
||||
case ServerCommand("sendrawtransaction", arr) =>
|
||||
withValidServerCommand(SendRawTransaction.fromJsArr(arr)) {
|
||||
case SendRawTransaction(tx) =>
|
||||
complete {
|
||||
wallet.broadcastTransaction(tx).map { _ =>
|
||||
Server.httpSuccess(tx.txIdBE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case ServerCommand("estimatefee", _) =>
|
||||
complete {
|
||||
wallet.getFeeRate.map { fee =>
|
||||
|
Loading…
Reference in New Issue
Block a user