-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #498 from alvasw/bitcoind_add_listdescriptors_rpc_…
…call Bitcoind: Add listdescriptors RPC call
- Loading branch information
Showing
6 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...itcoind/src/main/java/bisq/wallets/bitcoind/rpc/calls/BitcoindListDescriptorsRpcCall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.wallets.bitcoind.rpc.calls; | ||
|
||
import bisq.wallets.bitcoind.rpc.responses.BitcoindListDescriptorResponse; | ||
import bisq.wallets.core.rpc.call.WalletRpcCall; | ||
|
||
public class BitcoindListDescriptorsRpcCall | ||
extends WalletRpcCall<Void, BitcoindListDescriptorResponse> { | ||
|
||
public BitcoindListDescriptorsRpcCall() { | ||
super(null); | ||
} | ||
|
||
@Override | ||
public String getRpcMethodName() { | ||
return "listdescriptors"; | ||
} | ||
|
||
@Override | ||
public boolean isResponseValid(BitcoindListDescriptorResponse response) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public Class<BitcoindListDescriptorResponse> getRpcResponseClass() { | ||
return BitcoindListDescriptorResponse.class; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
wallets/bitcoind/src/main/java/bisq/wallets/bitcoind/rpc/responses/BitcoindDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.wallets.bitcoind.rpc.responses; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Setter | ||
public class BitcoindDescriptor { | ||
private String desc; | ||
private long timestamp; | ||
private boolean active; | ||
private boolean internal; | ||
private List<Integer> range; | ||
private Integer next; | ||
} |
32 changes: 32 additions & 0 deletions
32
...ind/src/main/java/bisq/wallets/bitcoind/rpc/responses/BitcoindListDescriptorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.wallets.bitcoind.rpc.responses; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Setter | ||
public class BitcoindListDescriptorResponse { | ||
@JsonProperty("wallet_name") | ||
private String walletName; | ||
private List<BitcoindDescriptor> descriptors; | ||
} |
48 changes: 48 additions & 0 deletions
48
.../bitcoind/src/test/java/bisq/wallets/bitcoind/BitcoindListDescriptorsIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.wallets.bitcoind; | ||
|
||
import bisq.wallets.bitcoind.regtest.BitcoindExtension; | ||
import bisq.wallets.bitcoind.rpc.BitcoindWallet; | ||
import bisq.wallets.bitcoind.rpc.responses.BitcoindDescriptor; | ||
import bisq.wallets.bitcoind.rpc.responses.BitcoindListDescriptorResponse; | ||
import bisq.wallets.regtest.bitcoind.BitcoindRegtestSetup; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@ExtendWith(BitcoindExtension.class) | ||
public class BitcoindListDescriptorsIntegrationTest { | ||
private final BitcoindWallet minerWallet; | ||
|
||
public BitcoindListDescriptorsIntegrationTest(BitcoindRegtestSetup regtestSetup) { | ||
this.minerWallet = regtestSetup.getMinerWallet(); | ||
} | ||
|
||
@Test | ||
void listDescriptorsTest() { | ||
BitcoindListDescriptorResponse response = minerWallet.listDescriptors(); | ||
List<BitcoindDescriptor> descriptorList = response.getDescriptors(); | ||
|
||
assertThat(descriptorList).isNotEmpty() | ||
.anySatisfy(descriptor -> assertThat(descriptor.getDesc()).startsWith("pkh([")); | ||
} | ||
} |